aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-02-10 10:38:15 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-02-10 10:38:15 +0100
commit48fe12520bb61fb5347409f0e5def5c5a552486f (patch)
treef22c9ccaf8d7ae5ee3094ca35f0088a55f854cef
parent67962f1277b483060a16b80cbe79fac56d4e2cc6 (diff)
cec-compliance: clarify obscure error message
The --expect option checks if the test result matches what is expected. If it isn't, then this message is shown: Dynamic Auto Lipsync feature: Request Current Latency: FAIL (Expected 0, got 3) That's not very clear, so this is now changed to: Dynamic Auto Lipsync feature: Request Current Latency: FAIL (Expected 'OK', got 'OK (Not Supported)') Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/cec-compliance/cec-compliance.cpp66
-rw-r--r--utils/cec-compliance/cec-compliance.h2
-rw-r--r--utils/cec-compliance/cec-test.cpp8
3 files changed, 44 insertions, 32 deletions
diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
index 6718799b..003b49a2 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -756,40 +756,48 @@ int cec_named_ioctl(struct node *node, const char *name,
return retval == -1 ? e : (retval ? -1 : 0);
}
+const char *result_name(int res, bool show_colors)
+{
+ switch (res) {
+ case OK_NOT_SUPPORTED:
+ return show_colors ? COLOR_GREEN("OK") " (Not Supported)" : "OK (Not Supported)";
+ case OK_PRESUMED:
+ return show_colors ? COLOR_GREEN("OK") " (Presumed)" : "OK (Presumed)";
+ case OK_REFUSED:
+ return show_colors ? COLOR_GREEN("OK") " (Refused)" : "OK (Refused)";
+ case OK_UNEXPECTED:
+ return show_colors ? COLOR_GREEN("OK") " (Unexpected)" : "OK (Unexpected)";
+ case OK_EXPECTED_FAIL:
+ return show_colors ? COLOR_GREEN("OK") " (Expected Failure)" : "OK (Expected Failure)";
+ case OK:
+ return show_colors ? COLOR_GREEN("OK") : "OK";
+ default:
+ return show_colors ? COLOR_RED("FAIL") : "FAIL";
+ }
+}
+
const char *ok(int res)
{
- static char buf[100];
-
- if (res == OK_NOT_SUPPORTED) {
- strcpy(buf, show_colors ? COLOR_GREEN("OK") " (Not Supported)" :
- "OK (Not Supported)");
- res = 0;
- } else if (res == OK_PRESUMED) {
- strcpy(buf, show_colors ? COLOR_GREEN("OK") " (Presumed)" :
- "OK (Presumed)");
- res = 0;
- } else if (res == OK_REFUSED) {
- strcpy(buf, show_colors ? COLOR_GREEN("OK") " (Refused)" :
- "OK (Refused)");
- res = 0;
- } else if (res == OK_UNEXPECTED) {
- strcpy(buf, show_colors ? COLOR_GREEN("OK") " (Unexpected)" :
- "OK (Unexpected)");
- res = 0;
- } else if (res == OK_EXPECTED_FAIL) {
- strcpy(buf, show_colors ? COLOR_GREEN("OK") " (Expected Failure)" :
- "OK (Expected Failure)");
- res = 0;
- } else
- strcpy(buf, show_colors ? COLOR_GREEN("OK") : "OK");
+ const char *res_name = result_name(res, show_colors);
+
+ switch (res) {
+ case OK_NOT_SUPPORTED:
+ case OK_PRESUMED:
+ case OK_REFUSED:
+ case OK_UNEXPECTED:
+ case OK_EXPECTED_FAIL:
+ case OK:
+ res = OK;
+ break;
+ default:
+ break;
+ }
tests_total++;
- if (res) {
+ if (res)
app_result = res;
- strcpy(buf, show_colors ? COLOR_RED("FAIL") : "FAIL");
- } else {
+ else
tests_ok++;
- }
- return buf;
+ return res_name;
}
int check_0(const void *p, int len)
diff --git a/utils/cec-compliance/cec-compliance.h b/utils/cec-compliance/cec-compliance.h
index 644a05a5..39a5402f 100644
--- a/utils/cec-compliance/cec-compliance.h
+++ b/utils/cec-compliance/cec-compliance.h
@@ -178,6 +178,7 @@ struct remote_subtest {
bool for_cec20;
};
+#define OK 0
#define FAIL 1
#define OK_PRESUMED 2
#define OK_NOT_SUPPORTED 3
@@ -396,6 +397,7 @@ static inline unsigned get_ts_ms()
return timespec.tv_sec * 1000ull + timespec.tv_nsec / 1000000;
}
+const char *result_name(int res, bool show_colors);
const char *ok(int res);
const char *power_status2s(__u8 power_status);
std::string short_audio_desc2s(const struct short_audio_desc &sad);
diff --git a/utils/cec-compliance/cec-test.cpp b/utils/cec-compliance/cec-test.cpp
index 45456fff..8d86f234 100644
--- a/utils/cec-compliance/cec-test.cpp
+++ b/utils/cec-compliance/cec-test.cpp
@@ -1592,10 +1592,12 @@ void testRemote(struct node *node, unsigned me, unsigned la, unsigned test_tags,
if (mapTests[safename(name)] != DONT_CARE) {
if (ret != mapTests[safename(name)])
- printf("\t %s: %s (Expected %d, got %d)\n",
- name, ok(FAIL), mapTests[safename(name)], ret);
+ printf("\t %s: %s (Expected '%s', got '%s')\n",
+ name, ok(FAIL),
+ result_name(mapTests[safename(name)], false),
+ result_name(ret, false));
else if (has_warnings && mapTestsNoWarnings[safename(name)])
- printf("\t %s: %s (Expected no warnings, got %d)\n",
+ printf("\t %s: %s (Expected no warnings, got %d warnings)\n",
name, ok(FAIL), warnings - old_warnings);
else if (ret == FAIL)
printf("\t %s: %s\n", name, ok(OK_EXPECTED_FAIL));

Privacy Policy