Fix integration tests 69/227969/3
authorMateusz Majewski <m.majewski2@samsung.com>
Tue, 17 Mar 2020 15:59:42 +0000 (16:59 +0100)
committerMateusz Majewski <m.majewski2@samsung.com>
Tue, 17 Mar 2020 16:42:15 +0000 (17:42 +0100)
Change-Id: I1ce295e95902e44d319999d98435434d14eb971f

tests/dlog_test.in
tests/test_libdlogutil.c

index 7f983da..3b50b2a 100644 (file)
@@ -564,10 +564,9 @@ line=`$cmd_prefix $format | $cmd_postfix`
 [[ "$line" == "rawformatTEST" ]] && ok || fail
 
 LOG_DETAILS="testing if KMSG works in the default format"
-# We check if the command returns at least 1000 logs. This seems to be a safe value. In my test,
-# my target reaches it in about 2 seconds after the boot. Feel free to change it to a reasonable
-# yet lower value if the test happens to fail otherwise, but it would be extremely surprising.
-[[ "$(dlogutil -db kmsg | wc -l)" -gt 1000 ]] && ok || fail
+# We check if the command returns at least 100 logs. This seems to be a safe value.
+# Feel free to change it to a reasonable yet lower value if the test happens to fail otherwise.
+[[ "$(dlogutil -db kmsg | wc -l)" -gt 100 ]] && ok || fail
 
 LOG_DETAILS="testing if KMSG works in the raw format"
 last_dmesg=`dmesg | tail -n1 | sed -re "s/^\[[ 0-9]{5,}\.[0-9]{6}\] (.*)$/\1/g"`
index 74d1eae..35fc588 100644 (file)
@@ -26,6 +26,12 @@ struct test_data {
        int ret;
 };
 
+bool compare_suffix(const char* string, const char *suffix)
+{
+       int add = (int)strlen(string) - strlen(suffix);
+       return add >= 0 && strcmp(string + add, suffix) == 0;
+}
+
 int test_callback(const dlogutil_entry_s *ent, void *var)
 {
        struct test_data *data = var;
@@ -50,12 +56,12 @@ int test_callback(const dlogutil_entry_s *ent, void *var)
 
        switch (prio) {
        case DLOG_ERROR:
-               if (strcmp(msg, "test_libdlog.c: main(61) > test data, level: error"))
+               if (!compare_suffix(msg, "test data, level: error"))
                        return -EINVAL;
                data->errors += 1;
                break;
        case DLOG_INFO:
-               if (strcmp(msg, "test_libdlog.c: main(63) > test data, level: info"))
+               if (!compare_suffix(msg, "test data, level: info"))
                        return -EINVAL;
                data->infos += 1;
                break;