test: fix prefix discovery

Message ID ccaf5f7c79b1da882dafdcd057585bd1bd20b150.1531747666.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series test: fix prefix discovery |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly July 16, 2018, 1:57 p.m. UTC
  Config file has moved, but the tests weren't updated to point to
its new location. Update the code to find current prefix.

Fixes: adf1d867361c ("eal: move runtime config file to new location")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_eal_flags.c    | 9 ++-------
 test/test/test_mp_secondary.c | 7 +------
 2 files changed, 3 insertions(+), 13 deletions(-)
  

Comments

Pattan, Reshma July 16, 2018, 3:21 p.m. UTC | #1
> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Monday, July 16, 2018 2:57 PM
> To: dev@dpdk.org
> Cc: Pattan, Reshma <reshma.pattan@intel.com>
> Subject: [PATCH] test: fix prefix discovery
> 
> Config file has moved, but the tests weren't updated to point to its new
> location. Update the code to find current prefix.
> 
> Fixes: adf1d867361c ("eal: move runtime config file to new location")
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Acked-by: Reshma Pattan <reshma.pattan@intel.com>
  

Patch

diff --git a/test/test/test_eal_flags.c b/test/test/test_eal_flags.c
index f840ca50b..e0887af21 100644
--- a/test/test/test_eal_flags.c
+++ b/test/test/test_eal_flags.c
@@ -234,13 +234,8 @@  get_current_prefix(char * prefix, int size)
 	if (readlink(path, buf, sizeof(buf)) == -1)
 		return NULL;
 
-	/* get the basename */
-	snprintf(buf, sizeof(buf), "%s", basename(buf));
-
-	/* copy string all the way from second char up to start of _config */
-	snprintf(prefix, size, "%.*s",
-			(int)(strnlen(buf, sizeof(buf)) - sizeof("_config")),
-			&buf[1]);
+	/* get the prefix */
+	snprintf(prefix, size, "%s", basename(dirname(buf)));
 
 	return prefix;
 }
diff --git a/test/test/test_mp_secondary.c b/test/test/test_mp_secondary.c
index cc46cf4de..8d22240cf 100644
--- a/test/test/test_mp_secondary.c
+++ b/test/test/test_mp_secondary.c
@@ -65,12 +65,7 @@  get_current_prefix(char * prefix, int size)
 		return NULL;
 
 	/* get the basename */
-	snprintf(buf, sizeof(buf), "%s", basename(buf));
-
-	/* copy string all the way from second char up to start of _config */
-	snprintf(prefix, size, "%.*s",
-			(int)(strnlen(buf, sizeof(buf)) - sizeof("_config")),
-			&buf[1]);
+	snprintf(prefix, size, "%s", basename(dirname(buf)));
 
 	return prefix;
 }