Commit 945de4a0687a4fedbd406da3489444324e070539

Thomas de Grivel 2024-07-24T18:31:19

fix test argv[0]

diff --git a/test/libkc3_test.c b/test/libkc3_test.c
index 9c466a7..d239efd 100644
--- a/test/libkc3_test.c
+++ b/test/libkc3_test.c
@@ -42,9 +42,9 @@ void types_test (void);
 
 int main (int argc, char **argv)
 {
-  test_init(&argc, &argv);
   if (! kc3_init(NULL, &argc, &argv))
     return 1;
+  test_init(g_kc3_env.argv[0], &argc, &argv);
   if (test_target("types")) {
     fprintf(stderr, "\ntypes\n");
     types_test();
@@ -149,8 +149,8 @@ int main (int argc, char **argv)
     fprintf(stderr, "\nenv\n");
     env_test();
   }
-  kc3_clean(NULL);
   test_summary();
   test_clean();
+  kc3_clean(NULL);
   return 0;
 }
diff --git a/test/test.c b/test/test.c
index 66b227c..c2d89e5 100644
--- a/test/test.c
+++ b/test/test.c
@@ -84,7 +84,7 @@ int test_file_compare (const char *path_a, const char *path_b)
   return 0;
 }
 
-void test_init (int *argc, char ***argv)
+void test_init (char *argv0, int *argc, char ***argv)
 {
   const char **t;
   if ((*argv)[(*argc)] != NULL)
@@ -119,7 +119,7 @@ void test_init (int *argc, char ***argv)
       g_test_targets = (const char **) g_test_targets_env_v;
     }
   }
-  printf("%s", (*argv)[0]);
+  printf("%s", argv0);
   t = g_test_targets;
   while (*t) {
     printf(" %s", *t);
diff --git a/test/test.h b/test/test.h
index 5cdb052..aa0e683 100644
--- a/test/test.h
+++ b/test/test.h
@@ -188,7 +188,7 @@ extern const char **g_test_targets;
 
 /* Init and clean. */
 void test_clean (void);
-void test_init (int *argc, char ***argv);
+void test_init (char *argv0, int *argc, char ***argv);
 
 /* Operators. */
 void test_context (const char *context);