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

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