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

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