~jamesodhunt/ubuntu/vivid/upstart/bug-1447756

« back to all changes in this revision

Viewing changes to init/tests/test_log.c

  • Committer: James Hunt
  • Date: 2014-03-11 15:23:07 UTC
  • mfrom: (1182.135.76 upstart)
  • mto: This revision was merged to the branch mainline in revision 1544.
  • Revision ID: james.hunt@ubuntu.com-20140311152307-ad1wi9qxurjrui8j
Tags: upstream-1.12.1
ImportĀ upstreamĀ versionĀ 1.12.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1136
1136
        int   pty_master;
1137
1137
        int   pty_slave;
1138
1138
        int   found_fd;
 
1139
        char  filename[1024];
 
1140
        int   fd;
1139
1141
 
1140
1142
        TEST_FUNCTION ("log_destroy");
1141
1143
 
1179
1181
 
1180
1182
        TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
1181
1183
 
1182
 
        log = log_new (NULL, "/bar", pty_master, 0);
 
1184
        TEST_FILENAME (filename);
 
1185
 
 
1186
        /* Make file inaccessible to ensure data cannot be written
 
1187
         * and will thus be added to the unflushed buffer.
 
1188
         */
 
1189
        fd = open (filename, O_CREAT | O_EXCL, 0);
 
1190
        TEST_NE (fd, -1);
 
1191
        close (fd);
 
1192
 
 
1193
        log = log_new (NULL, filename, pty_master, 0);
1183
1194
        TEST_NE_P (log, NULL);
1184
1195
 
1185
1196
        ret = write (pty_slave, str, strlen (str));
1200
1211
 
1201
1212
        TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
1202
1213
 
1203
 
        log = log_new (NULL, "/bar", pty_master, 0);
 
1214
        log = log_new (NULL, filename, pty_master, 0);
1204
1215
        TEST_NE_P (log, NULL);
1205
1216
 
1206
1217
        found_fd = 0;
1238
1249
                }
1239
1250
        }
1240
1251
 
 
1252
        TEST_EQ (unlink (filename), 0);
 
1253
 
1241
1254
        /* Freeing the log object should have removed the watch */
1242
1255
        TEST_EQ (found_fd, 0);
1243
1256