support/testing: test_syslog_ng: improve commands
authorRicardo Martincoski <ricardo.martincoski@gmail.com>
Wed, 16 Oct 2019 01:09:50 +0000 (22:09 -0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 16 Oct 2019 19:33:04 +0000 (21:33 +0200)
There is no need for double grep, so choose a better regexp. Use &&
instead of ; between commands so the sequence of commands fail faster.

Break the last sequence of commands in 2 calls run() so the proper
return code can be tested for each.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
support/testing/tests/package/test_syslog_ng.py

index 6cc7c18945bd21d131d89781923da12be2c19774..3fb0be5fb88a49f36bfd29f83912e27aa2db792d 100644 (file)
@@ -19,18 +19,20 @@ class TestSyslogNg(infra.basetest.BRTest):
                            options=["-initrd", cpio_file])
         self.emulator.login()
 
-        cmd = "grep syslog-ng /var/log/messages | grep starting"
+        cmd = "grep 'syslog-ng starting' /var/log/messages"
         _, exit_code = self.emulator.run(cmd)
         self.assertEqual(exit_code, 0)
 
-        cmd = "logger my-message;"
-        cmd += "sleep 1;"
+        cmd = "logger my-message && "
+        cmd += "sleep 1 && "
         cmd += "grep my-message /var/log/messages"
         _, exit_code = self.emulator.run(cmd)
         self.assertEqual(exit_code, 0)
 
-        cmd = "syslog-ng-ctl reload;"
-        cmd += "sleep 1;"
-        cmd += "grep syslog-ng /var/log/messages | grep -i warning"
+        cmd = "syslog-ng-ctl reload && "
+        cmd += "sleep 1"
+        _, exit_code = self.emulator.run(cmd)
+        self.assertEqual(exit_code, 0)
+        cmd = "grep -i 'syslog-ng.*warning' /var/log/messages"
         _, exit_code = self.emulator.run(cmd)
         self.assertEqual(exit_code, 1)