Blame SOURCES/0235-testsuite-fix-dd_open_item_file-test.patch

28bab8
From 073315ef39b1e0590d50db1618c04227f5f58e47 Mon Sep 17 00:00:00 2001
28bab8
From: Jakub Filak <jfilak@redhat.com>
28bab8
Date: Thu, 3 Nov 2016 15:26:19 +0100
28bab8
Subject: [PATCH] testsuite: fix dd_open_item_file test
28bab8
28bab8
There were a bug caused by the fact that an old deallocated FILE*
28bab8
variable was used instead of a new one.
28bab8
28bab8
-        fprintf(f_rdwr_time, "7654321");
28bab8
-        rewind(f_rdwr_noent);
28bab8
28bab8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
28bab8
---
28bab8
 tests/dump_dir.at | 82 +++++++++++++++++++++++++----------------------
28bab8
 1 file changed, 44 insertions(+), 38 deletions(-)
28bab8
28bab8
diff --git a/tests/dump_dir.at b/tests/dump_dir.at
28bab8
index 78ea60d1..dc95e5b9 100644
28bab8
--- a/tests/dump_dir.at
28bab8
+++ b/tests/dump_dir.at
28bab8
@@ -502,58 +502,64 @@ TS_MAIN
28bab8
 
28bab8
     TS_ASSERT_PTR_IS_NULL(dd_open_item_file(dd, "nofile", O_RDONLY));
28bab8
 
28bab8
-    FILE *const f_rdwr_noent = dd_open_item_file(dd, "nofile", O_RDWR);
28bab8
-    TS_ASSERT_PTR_IS_NOT_NULL(f_rdwr_noent);
28bab8
-    if (g_testsuite_last_ok) {
28bab8
-        fprintf(f_rdwr_noent, "%s", "f_rdwr_noent");
28bab8
-        rewind(f_rdwr_noent);
28bab8
+    {
28bab8
+        FILE *const f_rdwr_noent = dd_open_item_file(dd, "nofile", O_RDWR);
28bab8
+        TS_ASSERT_PTR_IS_NOT_NULL(f_rdwr_noent);
28bab8
+        if (g_testsuite_last_ok) {
28bab8
+            fprintf(f_rdwr_noent, "%s", "f_rdwr_noent");
28bab8
+            rewind(f_rdwr_noent);
28bab8
 
28bab8
-        char rdwr_contents[256];
28bab8
-        TS_ASSERT_PTR_IS_NOT_NULL(fgets(rdwr_contents, sizeof(rdwr_contents), f_rdwr_noent));
28bab8
-        TS_ASSERT_STRING_EQ(rdwr_contents, "f_rdwr_noent", "Successfully read data");
28bab8
-        fclose(f_rdwr_noent);
28bab8
+            char rdwr_contents[256];
28bab8
+            TS_ASSERT_PTR_IS_NOT_NULL(fgets(rdwr_contents, sizeof(rdwr_contents), f_rdwr_noent));
28bab8
+            TS_ASSERT_STRING_EQ(rdwr_contents, "f_rdwr_noent", "Successfully read data");
28bab8
+            fclose(f_rdwr_noent);
28bab8
 
28bab8
-        char *const noent_contents = dd_load_text(dd, "nofile");
28bab8
-        TS_ASSERT_STRING_EQ(noent_contents, "f_rdwr_noent", "Successfully wrote data");
28bab8
-        free(noent_contents);
28bab8
+            char *const noent_contents = dd_load_text(dd, "nofile");
28bab8
+            TS_ASSERT_STRING_EQ(noent_contents, "f_rdwr_noent", "Successfully wrote data");
28bab8
+            free(noent_contents);
28bab8
+        }
28bab8
     }
28bab8
 
28bab8
     TS_ASSERT_PTR_IS_NULL(dd_open_item_file(dd, "time", O_RDONLY | O_EXCL));
28bab8
 
28bab8
-    FILE *const f_rdonly_time = dd_open_item_file(dd, "time", O_RDONLY);
28bab8
-    TS_ASSERT_PTR_IS_NOT_NULL(f_rdonly_time);
28bab8
-    if (g_testsuite_last_ok) {
28bab8
-        char *time = dd_load_text(dd, "time");
28bab8
-        TS_ASSERT_PTR_IS_NOT_NULL(time);
28bab8
-
28bab8
-        char rdonly_time_contents[16];
28bab8
-        char *const res = fgets(rdonly_time_contents, sizeof(rdonly_time_contents), f_rdonly_time);
28bab8
-        TS_ASSERT_PTR_EQ(rdonly_time_contents, res);
28bab8
+    {
28bab8
+        FILE *const f_rdonly_time = dd_open_item_file(dd, "time", O_RDONLY);
28bab8
+        TS_ASSERT_PTR_IS_NOT_NULL(f_rdonly_time);
28bab8
         if (g_testsuite_last_ok) {
28bab8
-            TS_ASSERT_STRING_EQ(rdonly_time_contents, time, "Read only time");
28bab8
-        }
28bab8
-        else {
28bab8
-            TS_PRINTF("File 'time' read error: %s\n", strerror(errno));
28bab8
+            char *time = dd_load_text(dd, "time");
28bab8
+            TS_ASSERT_PTR_IS_NOT_NULL(time);
28bab8
+
28bab8
+            char rdonly_time_contents[16];
28bab8
+            char *const res = fgets(rdonly_time_contents, sizeof(rdonly_time_contents), f_rdonly_time);
28bab8
+            TS_ASSERT_PTR_EQ(rdonly_time_contents, res);
28bab8
+            if (g_testsuite_last_ok) {
28bab8
+                TS_ASSERT_STRING_EQ(rdonly_time_contents, time, "Read only time");
28bab8
+            }
28bab8
+            else {
28bab8
+                TS_PRINTF("File 'time' read error: %s\n", strerror(errno));
28bab8
+            }
28bab8
+            fclose(f_rdonly_time);
28bab8
         }
28bab8
-        fclose(f_rdonly_time);
28bab8
     }
28bab8
 
28bab8
     TS_ASSERT_PTR_IS_NULL(dd_open_item_file(dd, "time", O_RDWR | O_EXCL));
28bab8
 
28bab8
-    FILE *const f_rdwr_time = dd_open_item_file(dd, "time", O_RDWR);
28bab8
-    TS_ASSERT_PTR_IS_NOT_NULL(f_rdwr_time);
28bab8
-    if (g_testsuite_last_ok) {
28bab8
-        fprintf(f_rdwr_time, "7654321");
28bab8
-        rewind(f_rdwr_noent);
28bab8
+    {
28bab8
+        FILE *const f_rdwr_time = dd_open_item_file(dd, "time", O_RDWR);
28bab8
+        TS_ASSERT_PTR_IS_NOT_NULL(f_rdwr_time);
28bab8
+        if (g_testsuite_last_ok) {
28bab8
+            fprintf(f_rdwr_time, "7654321");
28bab8
+            rewind(f_rdwr_time);
28bab8
 
28bab8
-        char rdwr_contents[256];
28bab8
-        TS_ASSERT_PTR_IS_NOT_NULL(fgets(rdwr_contents, sizeof(rdwr_contents), f_rdwr_noent));
28bab8
-        TS_ASSERT_STRING_EQ(rdwr_contents, "7654321", "Successfully read time data");
28bab8
-        fclose(f_rdwr_time);
28bab8
+            char rdwr_contents[256];
28bab8
+            TS_ASSERT_PTR_IS_NOT_NULL(fgets(rdwr_contents, sizeof(rdwr_contents), f_rdwr_time));
28bab8
+            TS_ASSERT_STRING_EQ(rdwr_contents, "7654321", "Successfully read time data");
28bab8
+            fclose(f_rdwr_time);
28bab8
 
28bab8
-        char *const time_contents = dd_load_text(dd, "time");
28bab8
-        TS_ASSERT_STRING_EQ(time_contents, "7654321", "Successfully wrote time data");
28bab8
-        free(time_contents);
28bab8
+            char *const time_contents = dd_load_text(dd, "time");
28bab8
+            TS_ASSERT_STRING_EQ(time_contents, "7654321", "Successfully wrote time data");
28bab8
+            free(time_contents);
28bab8
+        }
28bab8
     }
28bab8
 
28bab8
     testsuite_dump_dir_delete(dd);
28bab8
-- 
28bab8
2.17.2
28bab8