diff options
author | Luca Deri <deri@ntop.org> | 2020-07-03 14:43:14 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-07-03 14:43:14 +0200 |
commit | 513c857631defa7c9b9c3416ce7f97eb2bfd061c (patch) | |
tree | 1e3051215f7ce81f4a1a3e04b7a8b9af6260e22e /example/ndpiReader.c | |
parent | f7b91b46fa621529d82158fda0f4343a776b7b86 (diff) |
Added unit test
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 8f0219caf..e4745990c 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -3498,6 +3498,25 @@ void bpf_filter_port_array_add(int filter_array[], int size, int port) { /* *********************************************** */ +void analysisUnitTest() { + struct ndpi_analyze_struct *s = ndpi_alloc_data_analysis(32); + u_int32_t i; + + for(i=0; i<256; i++) + ndpi_data_add_value(s, i); + + if(0) { + ndpi_data_print_window_values(s); + printf("Average: [all: %f][window: %f]\n", ndpi_data_average(s), ndpi_data_window_average(s)); + printf("Entropy: %f\n", ndpi_data_entropy(s)); + printf("StdDev: %f\n", ndpi_data_stddev(s)); + printf("Min/Max: %u/%u\n", ndpi_data_min(s), ndpi_data_max(s)); + } + + ndpi_free_data_analysis(s); +} + +/* *********************************************** */ /** @brief MAIN FUNCTION @@ -3528,7 +3547,7 @@ int orginal_main(int argc, char **argv) { serializerUnitTest(); analyzeUnitTest(); ndpi_self_check_host_match(); - + analysisUnitTest(); memset(ndpi_thread_info, 0, sizeof(ndpi_thread_info)); parseOptions(argc, argv); |