[PATCH] app/test: simplify getting the current file prefix

Marat Khalili marat.khalili at huawei.com
Mon Feb 23 12:21:30 CET 2026


> diff --git a/app/test/process.h b/app/test/process.h
> index 402dc4f96f..1ab5671943 100644
> --- a/app/test/process.h
> +++ b/app/test/process.h
> @@ -8,12 +8,11 @@
>  #include <errno.h>  /* errno */
>  #include <limits.h> /* PATH_MAX */
>  #ifndef RTE_EXEC_ENV_WINDOWS
> -#include <libgen.h> /* basename et al */
>  #include <sys/wait.h>
>  #endif
>  #include <stdlib.h> /* NULL */
>  #include <string.h> /* strerror */
> -#include <unistd.h> /* readlink */
> +#include <unistd.h>

Can we delete it entirely? Compiles for me at least.

>  #include <dirent.h>
> 
>  #include <rte_string_fns.h> /* strlcpy */
> @@ -239,17 +238,7 @@ file_prefix_arg(void)
>  static inline char *
>  get_current_prefix(char *prefix, int size)
>  {
> -	char buf[PATH_MAX];
> -
> -	/* get file for config (fd is always 3) return NULL on error */
> -	if (readlink("/proc/self/fd/3", buf, sizeof(buf)) == -1)
> -		return NULL;
> -
> -	/*
> -	 * path should be something like "/var/run/dpdk/config"
> -	 * which results in prefix of "dpdk"
> -	 */
> -	rte_basename(dirname(buf), prefix, size);
> +	rte_basename(rte_eal_get_runtime_dir(), prefix, size);
>  	return prefix;

Do we even need it as a separate function anymore?

>  }
> 
> @@ -260,12 +249,8 @@ file_prefix_arg(void)
>  	static char prefix[NAME_MAX + sizeof("--file-prefix=")];
>  	char tmp[NAME_MAX];
> 
> -	if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
> -		fprintf(stderr, "Error - unable to get current prefix!\n");
> -		return NULL;
> -	}
> -
> -	snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
> +	snprintf(prefix, sizeof(prefix), "--file-prefix=%s",
> +			get_current_prefix(tmp, sizeof(tmp)));
>  	return prefix;
>  #endif
>  }
> --
> 2.51.0

With or without comments above addressed,
Acked-by: Marat Khalili <marat.khalili at huawei.com>

Tested-by: Marat Khalili <marat.khalili at huawei.com>


More information about the dev mailing list