Merge authors:
  Steve Langasek (vorlon)
Related merge proposals:
  
https://code.launchpad.net/~vorlon/upstart/more-log-flushing-tests/+merge/196432
  proposed by: Steve Langasek (vorlon)
  review: Approve - James Hunt (jamesodhunt)
------------------------------------------------------------
revno: 1578 [merge]
committer: James Hunt <[email protected]>
branch nick: upstart
timestamp: Mon 2013-11-25 09:22:55 +0000
message:
  * Merge of lp:~vorlon/upstart/more-log-flushing-tests.
modified:
  ChangeLog
  init/tests/test_log.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'ChangeLog'
--- ChangeLog	2013-11-23 19:48:16 +0000
+++ ChangeLog	2013-11-25 09:22:55 +0000
@@ -5,6 +5,10 @@
 	  about is making sure that the deserialization output matches what
 	  was in the json - so check the numeric value, NOT the symbolic
 	  signal name.
+	* init/tests/test_log.c: don't assume the root filesystem is not
+	  writable.  If we want to make sure log data stays in the buffer
+	  instead of being flushed to disk, create a log file that we
+	  control and know can't be written to.
 
 2013-11-16  Dmitrijs Ledkovs  <[email protected]>
 

=== modified file 'init/tests/test_log.c'
--- init/tests/test_log.c	2013-06-25 09:19:05 +0000
+++ init/tests/test_log.c	2013-11-23 22:18:28 +0000
@@ -1136,6 +1136,8 @@
 	int   pty_master;
 	int   pty_slave;
 	int   found_fd;
+	char  filename[1024];
+	int   fd;
 
 	TEST_FUNCTION ("log_destroy");
 
@@ -1179,7 +1181,16 @@
 
 	TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
 
-	log = log_new (NULL, "/bar", pty_master, 0);
+	TEST_FILENAME (filename);
+
+	/* Make file inaccessible to ensure data cannot be written
+	 * and will thus be added to the unflushed buffer.
+	 */
+	fd = open (filename, O_CREAT | O_EXCL, 0);
+	TEST_NE (fd, -1);
+	close (fd);
+
+	log = log_new (NULL, filename, pty_master, 0);
 	TEST_NE_P (log, NULL);
 
 	ret = write (pty_slave, str, strlen (str));
@@ -1200,7 +1211,7 @@
 
 	TEST_EQ (openpty (&pty_master, &pty_slave, NULL, NULL, NULL), 0);
 
-	log = log_new (NULL, "/bar", pty_master, 0);
+	log = log_new (NULL, filename, pty_master, 0);
 	TEST_NE_P (log, NULL);
 
 	found_fd = 0;
@@ -1238,6 +1249,8 @@
 		}
 	}
 
+	TEST_EQ (unlink (filename), 0);
+
 	/* Freeing the log object should have removed the watch */
 	TEST_EQ (found_fd, 0);
 

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to