[PATCH v13 16/16] test: add test for pcap PMD

David Marchand david.marchand at redhat.com
Wed Apr 29 17:27:42 CEST 2026


On Tue, 10 Feb 2026 at 01:04, Stephen Hemminger
<stephen at networkplumber.org> wrote:
>
> This test was generated by Claude AI with some prompting and
> pointing at existing ring PMD test. It tests basic operations,
> timestamps, jumbo frame, vlan handling and multiple queues
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>

[...]

> +
> +#ifdef RTE_EXEC_ENV_WINDOWS
> +
> +/*
> + * Helper: Create a unique temporary file path (Windows version)
> + */
> +static int
> +create_temp_path(char *buf, size_t buflen, const char *prefix)
> +{
> +       char temp_dir[MAX_PATH];
> +       char temp_file[MAX_PATH];
> +       DWORD ret;
> +
> +       ret = GetTempPathA(sizeof(temp_dir), temp_dir);
> +       if (ret == 0 || ret > sizeof(temp_dir))
> +               return -1;
> +
> +       if (GetTempFileNameA(temp_dir, prefix, 0, temp_file) == 0)
> +               return -1;
> +
> +       ret = snprintf(buf, buflen, "%s.pcap", temp_file);
> +       if (ret >= buflen) {
> +               DeleteFileA(temp_file);
> +               return -1;
> +       }
> +
> +       if (MoveFileA(temp_file, buf) == 0) {
> +               DeleteFileA(temp_file);
> +               return -1;
> +       }
> +
> +       return 0;
> +}
> +
> +/*
> + * Helper: Remove temporary file (Windows version)
> + */
> +static inline void
> +remove_temp_file(const char *path)
> +{
> +       if (path[0] != '\0')
> +               DeleteFileA(path);
> +}
> +
> +#else /* POSIX */
> +
> +/*
> + * Helper: Create a unique temporary file path (POSIX version)
> + */
> +static int
> +create_temp_path(char *buf, size_t buflen, const char *prefix)
> +{
> +       int fd;
> +
> +       snprintf(buf, buflen, "/tmp/%s_XXXXXX.pcap", prefix);
> +       fd = mkstemps(buf, 5);  /* 5 = strlen(".pcap") */
> +       if (fd < 0)
> +               return -1;
> +       close(fd);
> +       return 0;
> +}
> +
> +/*
> + * Helper: Remove temporary file (POSIX version)
> + */
> +static inline void
> +remove_temp_file(const char *path)
> +{
> +       if (path[0] != '\0')
> +               unlink(path);
> +}
> +
> +#endif /* RTE_EXEC_ENV_WINDOWS */

At a quick glance, that would make it the 3rd unit test having such
temp file manipulation helpers.
Could we put it in some app/test/ common file?


-- 
David Marchand



More information about the dev mailing list