diff options
| author | zhuzhenjun <[email protected]> | 2023-10-23 14:54:19 +0800 |
|---|---|---|
| committer | zhuzhenjun <[email protected]> | 2023-10-23 14:57:38 +0800 |
| commit | e80ae01d6826e5bc30cf8229f7d8c8cfcf29466e (patch) | |
| tree | cf7a43ba5617e872410b216f71f83e0a4afa2621 /test | |
| parent | 50e455bf8e3e24d579ee60cf242c45ac7b9f5eb3 (diff) | |
test: show prefilter stats8-p0f
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/test.c b/test/test.c index bdce05b..3cb0206 100644 --- a/test/test.c +++ b/test/test.c @@ -181,6 +181,8 @@ void test_miss_rate() unsigned int other_count = 0; unsigned int unknown_count = 0; unsigned int identify_failed_count = 0; + unsigned int prefiltered_count = 0; + unsigned int prefiltered_wrong_count = 0; unsigned int wrong_count = 0; unsigned int verified_count = 0; unsigned int fingerprint_count = 0; @@ -221,6 +223,12 @@ void test_miss_rate() const char *fp_str = cJSON_PrintUnformatted(entry); + struct osfp_fingerprint fp = {0}; + osfp_fingerprint_from_json(&fp, (char*)fp_str); + char str_buf[2048] = ""; + osfp_fingerprint_to_json_buf(&fp, str_buf, 2048, 0); + fprintf(log_file_ptr, "%s\n", str_buf); + struct osfp_result *result = osfp_json_identify(osfp_db, fp_str); if (result == NULL) { identify_failed_count++; @@ -229,12 +237,19 @@ void test_miss_rate() testresult[result->likely_os_class][os_class]++; + if (result->details[result->likely_os_class].score == 100) { + prefiltered_count++; + } + if (os_class == result->likely_os_class) { verified_count++; osfp_result_free(result); continue; } + if (result->details[result->likely_os_class].score == 100) { + prefiltered_wrong_count++; + } wrong_count++; if (result->likely_os_class == OSFP_OS_CLASS_OTHERS) { @@ -245,7 +260,7 @@ void test_miss_rate() unknown_count++; } - fprintf(log_file_ptr, "expect: %s, result: %s\n", os_class_json->valuestring, osfp_result_os_name_get(result)); + fprintf(log_file_ptr, "expect: %s, result: %s, \n", os_class_json->valuestring, osfp_result_os_name_get(result)); char *result_json = osfp_result_score_detail_export(result); if (result_json) { @@ -258,8 +273,8 @@ void test_miss_rate() } } - printf("total %u, failed %u, pass %u, wrong %u, other %u, unknown %u\n", - fingerprint_count, identify_failed_count, verified_count, wrong_count, other_count, unknown_count); + printf("total %u, failed %u, pass %u, prefiltered %u (wrong: %u), wrong %u, other %u, unknown %u\n", + fingerprint_count, identify_failed_count, verified_count, prefiltered_count, prefiltered_wrong_count, wrong_count, other_count, unknown_count); //printf("miss rate: %d%%\n", 100 - (verified_count * 100 / fingerprint_count)); |
