Commit 5ba1ef8619a1b14bf94cea6525ed9a648dd2a229

Thomas de Grivel 2023-01-22T13:08:35

check for system result

diff --git a/test/facts_test.c b/test/facts_test.c
index f8c4c0b..eab6b15 100644
--- a/test/facts_test.c
+++ b/test/facts_test.c
@@ -450,9 +450,13 @@ void facts_test_open_file ()
     "-0x10000000000000001",
     NULL
   };
+  sw r;
   s_fact fact;
   s_facts facts;
-  system("cp facts_test_open_file.1.in.facts facts_test_open_file.1.facts");
+  if ((r = system("cp facts_test_open_file.1.in.facts facts_test_open_file.1.facts")) < 0)
+    err(1, "%s:%i: cp", __FILE__, __LINE__);
+  if (r > 0)
+    errx(1, "%s:%i: cp", __FILE__, __LINE__);
   facts_init(&facts);
   TEST_EQ(facts_open_file(&facts,
                           "facts_test_open_file.1.facts"),
@@ -481,7 +485,10 @@ void facts_test_open_file ()
   if (g_test_last_ok)
     unlink("facts_test_open_file.1.facts");
   facts_init(&facts);
-  system("cp facts_test_open_file.2.in.facts facts_test_open_file.2.facts");
+  if ((r = system("cp facts_test_open_file.2.in.facts facts_test_open_file.2.facts")) < 0)
+    err(1, "%s:%i: cp", __FILE__, __LINE__);
+  if (r > 0)
+    errx(1, "%s:%i: cp", __FILE__, __LINE__);
   TEST_EQ(facts_open_file(&facts,
                           "facts_test_open_file.2.facts"),
           1531);
@@ -506,7 +513,10 @@ void facts_test_open_file ()
   if (g_test_last_ok)
     unlink("facts_test_open_file.2.facts");
   facts_init(&facts);
-  system("cp facts_test_open_file.3.in.facts facts_test_open_file.3.facts");
+  if ((r = system("cp facts_test_open_file.3.in.facts facts_test_open_file.3.facts")) < 0)
+    err(1, "%s:%i: cp", __FILE__, __LINE__);
+  if (r > 0)
+    errx(1, "%s:%i: cp", __FILE__, __LINE__);
   TEST_EQ(facts_open_file(&facts,
                           "facts_test_open_file.3.facts"),
           1588);