wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
65 stars 32 forks source link

QA testing - Avoid errno value in unit tests #3168

Closed vikman90 closed 2 years ago

vikman90 commented 2 years ago
Target version Related issue Related PR
4.3.7 https://github.com/wazuh/wazuh/issues/14502 https://github.com/wazuh/wazuh/pull/14518

Description

This PR aims to fix a set of failure results reported by the unit tests.

Proposed checks

image

Steps to reproduce

The problem appeared intermitently.

Expected results

Tests must pass.

QU3B1M commented 2 years ago

Review data

Tester PR commit
@QU3B1M ffb6eeb

Testing environment

OS OS version Deployment Image/AMI Notes
Ubuntu 20.04 LOCAL \| Vagrant bento/ubuntu-20.04

Status

QU3B1M commented 2 years ago

Run CMocka unit tests for server.

Test Execution on master :red_circle: - Install the required dependencies ([the ones used here](https://github.com/wazuh/wazuh/tree/master/src/unit_tests#unit-tests)) - Download & extract wazuh master `curl -Ls https://github.com/wazuh/wazuh/archive/v4.3.6.tar.gz | tar zx` - Compile wazuh server with the _debug_ and _test_ flags `cd wazuh/src/ && make deps` `make TARGET=server DEBUG=1 TEST=1` - Compile Unit Tests `mkdir unit_tests/build/ && cd unit_tests/build/` `cmake -DTARGET=server ..` `make` - Execute CMOCKA Unit Tests `ctest` ```bash Test project /home/vagrant/wazuh-4.3.6/src/unit_tests/build Start 1: test_analysisd_syscheck 1/138 Test #1: test_analysisd_syscheck ................. Passed 0.12 sec Start 2: test_dbsync 2/138 Test #2: test_dbsync ............................. Passed 0.10 sec Start 3: test_exec 3/138 Test #3: test_exec ............................... Passed 0.11 sec Start 4: test_log 4/138 Test #4: test_log ................................ Passed 0.11 sec Start 5: test_labels 5/138 Test #5: test_labels ............................. Passed 0.10 sec Start 6: test_mitre 6/138 Test #6: test_mitre .............................. Passed 0.02 sec Start 7: test_rules 7/138 Test #7: test_rules .............................. Passed 0.10 sec Start 8: test_same_different_loop 8/138 Test #8: test_same_different_loop ................ Passed 0.11 sec Start 9: test_logtest 9/138 Test #9: test_logtest ............................ Passed 0.06 sec Start 10: test_logtest-config 10/138 Test #10: test_logtest-config ..................... Passed 0.02 sec Start 11: test_decoder_list 11/138 Test #11: test_decoder_list ....................... Passed 0.02 sec Start 12: test_decode-xml 12/138 Test #12: test_decode-xml ......................... Passed 0.09 sec Start 13: test_lists_list 13/138 Test #13: test_lists_list ......................... Passed 0.02 sec Start 14: test_rule_list 14/138 Test #14: test_rule_list .......................... Passed 0.03 sec Start 15: test_eventinfo_list 15/138 Test #15: test_eventinfo_list ..................... Passed 0.02 sec Start 16: test_logmsg 16/138 Test #16: test_logmsg ............................. Passed 0.02 sec Start 17: test_decoder_rootcheck 17/138 Test #17: test_decoder_rootcheck .................. Passed 0.10 sec Start 18: test_decoder_syscollector 18/138 Test #18: test_decoder_syscollector ............... Passed 0.10 sec Start 19: test_manager 19/138 Test #19: test_manager ............................ Passed 0.09 sec Start 20: test_secure 20/138 Test #20: test_secure ............................. Passed 0.09 sec Start 21: test_netbuffer 21/138 Test #21: test_netbuffer .......................... Passed 0.09 sec Start 22: test_sendmsg 22/138 Test #22: test_sendmsg ............................ Passed 0.09 sec Start 23: test_remote-config 23/138 Test #23: test_remote-config ...................... Passed 0.02 sec Start 24: test_syslogtcp 24/138 Test #24: test_syslogtcp .......................... Passed 0.08 sec Start 25: test_wdb_integrity 25/138 Test #25: test_wdb_integrity ...................... Passed 0.02 sec Start 26: test_wdb_fim 26/138 Test #26: test_wdb_fim ............................ Passed 0.03 sec Start 27: test_wdb_parser 27/138 Test #27: test_wdb_parser ......................... Passed 0.04 sec Start 28: test_wdb_global_parser 28/138 Test #28: test_wdb_global_parser .................. Passed 0.05 sec Start 29: test_wdb_global 29/138 Test #29: test_wdb_global ......................... Passed 0.10 sec Start 30: test_wdb_agents 30/138 Test #30: test_wdb_agents ......................... Passed 0.02 sec Start 31: test_wdb_global_helpers 31/138 Test #31: test_wdb_global_helpers ................. Passed 0.04 sec Start 32: test_wdb_agents_helpers 32/138 Test #32: test_wdb_agents_helpers ................. Passed 0.03 sec Start 33: test_wdb 33/138 Test #33: test_wdb ................................ Passed 0.03 sec Start 34: test_wdb_upgrade 34/138 Test #34: test_wdb_upgrade ........................ Passed 0.02 sec Start 35: test_wdb_metadata 35/138 Test #35: test_wdb_metadata ....................... Passed 0.02 sec Start 36: test_wdb_task_parser 36/138 Test #36: test_wdb_task_parser .................... Passed 0.03 sec Start 37: test_wdb_rootcheck 37/138 Test #37: test_wdb_rootcheck ...................... Passed 0.02 sec Start 38: test_wdb_task 38/138 Test #38: test_wdb_task ........................... Passed 0.02 sec Start 39: test_wdb_syscollector 39/138 Test #39: test_wdb_syscollector ................... Passed 0.03 sec Start 40: test_auth_parse 40/138 Test #40: test_auth_parse ......................... Passed 0.03 sec Start 41: test_auth_validate 41/138 Test #41: test_auth_validate ...................... Passed 0.03 sec Start 42: test_auth_add 42/138 Test #42: test_auth_add ........................... Passed 0.03 sec Start 43: test_ssl 43/138 Test #43: test_ssl ................................ Passed 0.02 sec Start 44: test_auth 44/138 Test #44: test_auth ............................... Passed 0.03 sec Start 45: test_msgs 45/138 Test #45: test_msgs ............................... Passed 0.02 sec Start 46: test_keys 46/138 Test #46: test_keys ............................... Passed 0.02 sec Start 47: test_sha1_op 47/138 Test #47: test_sha1_op ............................ Passed 0.02 sec Start 48: test_blowfish_op 48/138 Test #48: test_blowfish_op ........................ Passed 0.02 sec Start 49: test_md5_op 49/138 Test #49: test_md5_op ............................. Passed 0.02 sec Start 50: test_md5_sha1_op 50/138 Test #50: test_md5_sha1_op ........................ Passed 0.02 sec Start 51: test_wm_aws 51/138 Test #51: test_wm_aws ............................. Passed 0.08 sec Start 52: test_wm_azure 52/138 Test #52: test_wm_azure ........................... Passed 0.08 sec Start 53: test_wm_ciscat 53/138 Test #53: test_wm_ciscat .......................... Passed 0.07 sec Start 54: test_wm_command 54/138 Test #54: test_wm_command ......................... Passed 0.08 sec Start 55: test_wm_docker 55/138 Test #55: test_wm_docker .......................... Passed 0.08 sec Start 56: test_wm_gcp 56/138 Test #56: test_wm_gcp ............................. Passed 0.03 sec Start 57: test_wmodules_gcp 57/138 Test #57: test_wmodules_gcp ....................... Passed 0.10 sec Start 58: test_wm_oscap 58/138 Test #58: test_wm_oscap ........................... Passed 0.07 sec Start 59: test_wm_sca 59/138 Test #59: test_wm_sca ............................. Passed 0.07 sec Start 60: test_wmodules_scheduling 60/138 Test #60: test_wmodules_scheduling ................ Passed 0.02 sec Start 61: test_wm_vuln_detector 61/138 Test #61: test_wm_vuln_detector ................... Passed 0.13 sec Start 62: test_wm_vuln_detector_evr 62/138 Test #62: test_wm_vuln_detector_evr ............... Passed 0.02 sec Start 63: test_wm_vuln_detector_nvd 63/138 Test #63: test_wm_vuln_detector_nvd ............... Passed 0.08 sec Start 64: test_wm_task_manager 64/138 Test #64: test_wm_task_manager .................... Passed 0.03 sec Start 65: test_wm_task_manager_parsing 65/138 Test #65: test_wm_task_manager_parsing ............ Passed 0.02 sec Start 66: test_wm_task_manager_commands 66/138 Test #66: test_wm_task_manager_commands ........... Passed 0.03 sec Start 67: test_wm_agent_upgrade 67/138 Test #67: test_wm_agent_upgrade ................... Passed 0.02 sec Start 68: test_wm_agent_upgrade_manager 68/138 Test #68: test_wm_agent_upgrade_manager ........... Passed 0.02 sec Start 69: test_wm_agent_upgrade_parsing 69/138 Test #69: test_wm_agent_upgrade_parsing ........... Passed 0.03 sec Start 70: test_wm_agent_upgrade_validate 70/138 Test #70: test_wm_agent_upgrade_validate .......... Passed 0.03 sec Start 71: test_wm_agent_upgrade_tasks 71/138 Test #71: test_wm_agent_upgrade_tasks ............. Passed 0.02 sec Start 72: test_wm_agent_upgrade_tasks_callbacks 72/138 Test #72: test_wm_agent_upgrade_tasks_callbacks ... Passed 0.03 sec Start 73: test_wm_agent_upgrade_commands 73/138 Test #73: test_wm_agent_upgrade_commands .......... Passed 0.03 sec Start 74: test_wm_agent_upgrade_upgrades 74/138 Test #74: test_wm_agent_upgrade_upgrades .......... Passed 0.05 sec Start 75: test_wm_github 75/138 Test #75: test_wm_github .......................... Passed 0.09 sec Start 76: test_wm_office365 76/138 Test #76: test_wm_office365 ....................... Passed 0.11 sec Start 77: test_monitord 77/138 Test #77: test_monitord ........................... Passed 0.03 sec Start 78: test_monitor_actions 78/138 Test #78: test_monitor_actions .................... Passed 0.07 sec Start 79: test_logcollector 79/138 Test #79: test_logcollector ....................... Passed 0.11 sec Start 80: test_read_multiline_regex 80/138 Test #80: test_read_multiline_regex ............... Passed 0.08 sec Start 81: test_localfile-config 81/138 Test #81: test_localfile-config ................... Passed 0.07 sec Start 82: test_state 82/138 Test #82: test_state .............................. Passed 0.02 sec Start 83: test_lccom 83/138 Test #83: test_lccom .............................. Passed 0.08 sec Start 84: test_macos_log 84/138 Test #84: test_macos_log .......................... Passed 0.03 sec Start 85: test_read_macos 85/138 Test #85: test_read_macos ......................... Passed 0.14 sec Start 86: test_execd 86/138 Test #86: test_execd .............................. Passed 0.13 sec Start 87: test_create_db 87/138 Test #87: test_create_db .......................... Passed 0.14 sec Start 88: test_syscom 88/138 Test #88: test_syscom ............................. Passed 0.02 sec Start 89: test_fim_diff_changes 89/138 Test #89: test_fim_diff_changes ................... Passed 0.08 sec Start 90: test_run_realtime 90/138 Test #90: test_run_realtime ....................... Passed 0.09 sec Start 91: test_syscheck_config 91/138 Test #91: test_syscheck_config .................... Passed 0.11 sec Start 92: test_syscheck 92/138 Test #92: test_syscheck ........................... Passed 0.02 sec Start 93: test_fim_sync 93/138 Test #93: test_fim_sync ........................... Passed 0.13 sec Start 94: test_run_check 94/138 Test #94: test_run_check .......................... Passed 0.14 sec Start 95: test_fim_db 95/138 Test #95: test_fim_db ............................. Passed 0.09 sec Start 96: test_fim_db_files 96/138 Test #96: test_fim_db_files ....................... Passed 0.09 sec Start 97: test_audit_healthcheck 97/138 Test #97: test_audit_healthcheck .................. Passed 0.03 sec Start 98: test_audit_rule_handling 98/138 Test #98: test_audit_rule_handling ................ Passed 0.05 sec Start 99: test_syscheck_audit 99/138 Test #99: test_syscheck_audit ..................... Passed 0.09 sec Start 100: test_audit_parse 100/138 Test #100: test_audit_parse ........................ Passed 0.07 sec Start 101: test_list_op 101/138 Test #101: test_list_op ............................ Passed 0.03 sec Start 102: test_file_op 102/138 Test #102: test_file_op ............................ Passed 0.02 sec Start 103: test_integrity_op 103/138 Test #103: test_integrity_op ....................... Passed 0.01 sec Start 104: test_rbtree_op 104/138 Test #104: test_rbtree_op .......................... Passed 0.02 sec Start 105: test_validate_op 105/138 Test #105: test_validate_op ........................ Passed 0.01 sec Start 106: test_string_op 106/138 Test #106: test_string_op .......................... Passed 0.02 sec Start 107: test_expression 107/138 Test #107: test_expression ......................... Passed 0.02 sec Start 108: test_version_op 108/138 Test #108: test_version_op ......................... Passed 0.02 sec Start 109: test_queue_op 109/138 Test #109: test_queue_op ........................... Passed 0.02 sec Start 110: test_queue_linked_op 110/138 Test #110: test_queue_linked_op .................... Passed 0.02 sec Start 111: test_agent_op 111/138 Test #111: test_agent_op ........................... Passed 0.02 sec Start 112: test_set_agent_group 112/138 Test #112: test_set_agent_group .................... Passed 0.02 sec Start 113: test_enrollment_op 113/138 Test #113: test_enrollment_op ...................... Passed 0.04 sec Start 114: test_time_op 114/138 Test #114: test_time_op ............................ Passed 0.01 sec Start 115: test_buffer_op 115/138 Test #115: test_buffer_op .......................... Passed 0.01 sec Start 116: test_utf8_op 116/138 Test #116: test_utf8_op ............................ Passed 0.02 sec Start 117: test_log_builder 117/138 Test #117: test_log_builder ........................ Passed 0.02 sec Start 118: test_custom_output_search_replace 118/138 Test #118: test_custom_output_search_replace ....... Passed 0.01 sec Start 119: test_bzip2_op 119/138 Test #119: test_bzip2_op ........................... Passed 0.02 sec Start 120: test_schedule_scan 120/138 Test #120: test_schedule_scan ...................... Passed 0.02 sec Start 121: test_rootcheck_op 121/138 Test #121: test_rootcheck_op ....................... Passed 0.02 sec Start 122: test_fs_op 122/138 Test #122: test_fs_op .............................. Passed 0.01 sec Start 123: test_wazuhdb_op 123/138 Test #123: test_wazuhdb_op ......................... Passed 0.02 sec Start 124: test_syscheck_op 124/138 Test #124: test_syscheck_op ........................ Passed 0.05 sec Start 125: test_audit_op 125/138 Test #125: test_audit_op ........................... Passed 0.02 sec Start 126: test_privsep_op 126/138 Test #126: test_privsep_op ......................... Passed 0.01 sec Start 127: test_mq_op 127/138 Test #127: test_mq_op .............................. Passed 0.02 sec Start 128: test_remoted_op 128/138 Test #128: test_remoted_op ......................... Passed 0.02 sec Start 129: test_json-queue 129/138 Test #129: test_json-queue ......................... Passed 0.01 sec Start 130: test_bqueue 130/138 Test #130: test_bqueue ............................. Passed 0.02 sec Start 131: test_atomic 131/138 Test #131: test_atomic ............................. Passed 0.01 sec Start 132: test_url 132/138 Test #132: test_url ................................ Passed 0.02 sec Start 133: test_sysinfo_utils 133/138 Test #133: test_sysinfo_utils ...................... Passed 0.02 sec Start 134: test_os_xml 134/138 Test #134: test_os_xml ............................. Passed 0.05 sec Start 135: test_os_regex 135/138 Test #135: test_os_regex ........................... Passed 0.02 sec Start 136: test_os_zlib 136/138 Test #136: test_os_zlib ............................ Passed 0.02 sec Start 137: test_os_net 137/138 Test #137: test_os_net ............................. Passed 0.02 sec Start 138: test_fluentd_forwarder 138/138 Test #138: test_fluentd_forwarder .................. Passed 0.02 sec 100% tests passed, 0 tests failed out of 138 Total Test time (real) = 6.68 sec ```
Test Execution on branch with the FIX :green_circle: - Install the required dependencies ([the ones used here](https://github.com/wazuh/wazuh/tree/master/src/unit_tests#unit-tests)) - Clone the wazuh repo specifying the branch with the fix (`14502-logcollector-unit-test-failure`) `git clone https://github.com/wazuh/wazuh.git -b 14502-logcollector-unit-test-failure` - Compile wazuh server with the _debug_ and _test_ flags `cd wazuh/src/ && make deps` `make TARGET=server DEBUG=1 TEST=1` - Compile Unit Tests `mkdir unit_tests/build/ && cd unit_tests/build/` `cmake -DTARGET=server ..` `make` - Execute CMOCKA Unit Tests `ctest` ```bash Test project /home/vagrant/wazuh/src/unit_tests/build Start 1: test_analysisd_syscheck 1/139 Test #1: test_analysisd_syscheck ................. Passed 0.13 sec Start 2: test_dbsync 2/139 Test #2: test_dbsync ............................. Passed 0.12 sec Start 3: test_exec 3/139 Test #3: test_exec ............................... Passed 0.12 sec Start 4: test_log 4/139 Test #4: test_log ................................ Passed 0.11 sec Start 5: test_labels 5/139 Test #5: test_labels ............................. Passed 0.09 sec Start 6: test_mitre 6/139 Test #6: test_mitre .............................. Passed 0.02 sec Start 7: test_rules 7/139 Test #7: test_rules .............................. Passed 0.10 sec Start 8: test_same_different_loop 8/139 Test #8: test_same_different_loop ................ Passed 0.09 sec Start 9: test_logtest 9/139 Test #9: test_logtest ............................ Passed 0.06 sec Start 10: test_logtest-config 10/139 Test #10: test_logtest-config ..................... Passed 0.02 sec Start 11: test_decoder_list 11/139 Test #11: test_decoder_list ....................... Passed 0.02 sec Start 12: test_decode-xml 12/139 Test #12: test_decode-xml ......................... Passed 0.09 sec Start 13: test_lists_list 13/139 Test #13: test_lists_list ......................... Passed 0.02 sec Start 14: test_rule_list 14/139 Test #14: test_rule_list .......................... Passed 0.02 sec Start 15: test_eventinfo_list 15/139 Test #15: test_eventinfo_list ..................... Passed 0.02 sec Start 16: test_logmsg 16/139 Test #16: test_logmsg ............................. Passed 0.02 sec Start 17: test_decoder_rootcheck 17/139 Test #17: test_decoder_rootcheck .................. Passed 0.10 sec Start 18: test_decoder_syscollector 18/139 Test #18: test_decoder_syscollector ............... Passed 0.10 sec Start 19: test_manager 19/139 Test #19: test_manager ............................ Passed 0.09 sec Start 20: test_secure 20/139 Test #20: test_secure ............................. Passed 0.09 sec Start 21: test_netbuffer 21/139 Test #21: test_netbuffer .......................... Passed 0.08 sec Start 22: test_sendmsg 22/139 Test #22: test_sendmsg ............................ Passed 0.08 sec Start 23: test_remote-config 23/139 Test #23: test_remote-config ...................... Passed 0.02 sec Start 24: test_syslogtcp 24/139 Test #24: test_syslogtcp .......................... Passed 0.08 sec Start 25: test_wdb_integrity 25/139 Test #25: test_wdb_integrity ...................... Passed 0.02 sec Start 26: test_wdb_fim 26/139 Test #26: test_wdb_fim ............................ Passed 0.03 sec Start 27: test_wdb_parser 27/139 Test #27: test_wdb_parser ......................... Passed 0.03 sec Start 28: test_wdb_global_parser 28/139 Test #28: test_wdb_global_parser .................. Passed 0.04 sec Start 29: test_wdb_global 29/139 Test #29: test_wdb_global ......................... Passed 0.10 sec Start 30: test_wdb_agents 30/139 Test #30: test_wdb_agents ......................... Passed 0.02 sec Start 31: test_wdb_global_helpers 31/139 Test #31: test_wdb_global_helpers ................. Passed 0.03 sec Start 32: test_wdb_agents_helpers 32/139 Test #32: test_wdb_agents_helpers ................. Passed 0.03 sec Start 33: test_wdb 33/139 Test #33: test_wdb ................................ Passed 0.03 sec Start 34: test_wdb_upgrade 34/139 Test #34: test_wdb_upgrade ........................ Passed 0.03 sec Start 35: test_wdb_metadata 35/139 Test #35: test_wdb_metadata ....................... Passed 0.02 sec Start 36: test_wdb_task_parser 36/139 Test #36: test_wdb_task_parser .................... Passed 0.03 sec Start 37: test_wdb_rootcheck 37/139 Test #37: test_wdb_rootcheck ...................... Passed 0.02 sec Start 38: test_wdb_task 38/139 Test #38: test_wdb_task ........................... Passed 0.02 sec Start 39: test_wdb_syscollector 39/139 Test #39: test_wdb_syscollector ................... Passed 0.03 sec Start 40: test_auth_parse 40/139 Test #40: test_auth_parse ......................... Passed 0.03 sec Start 41: test_auth_validate 41/139 Test #41: test_auth_validate ...................... Passed 0.04 sec Start 42: test_auth_add 42/139 Test #42: test_auth_add ........................... Passed 0.03 sec Start 43: test_ssl 43/139 Test #43: test_ssl ................................ Passed 0.02 sec Start 44: test_auth 44/139 Test #44: test_auth ............................... Passed 0.03 sec Start 45: test_msgs 45/139 Test #45: test_msgs ............................... Passed 0.03 sec Start 46: test_keys 46/139 Test #46: test_keys ............................... Passed 0.03 sec Start 47: test_sha1_op 47/139 Test #47: test_sha1_op ............................ Passed 0.02 sec Start 48: test_blowfish_op 48/139 Test #48: test_blowfish_op ........................ Passed 0.01 sec Start 49: test_md5_op 49/139 Test #49: test_md5_op ............................. Passed 0.02 sec Start 50: test_md5_sha1_op 50/139 Test #50: test_md5_sha1_op ........................ Passed 0.02 sec Start 51: test_wm_aws 51/139 Test #51: test_wm_aws ............................. Passed 0.08 sec Start 52: test_wm_azure 52/139 Test #52: test_wm_azure ........................... Passed 0.08 sec Start 53: test_wm_ciscat 53/139 Test #53: test_wm_ciscat .......................... Passed 0.08 sec Start 54: test_wm_command 54/139 Test #54: test_wm_command ......................... Passed 0.09 sec Start 55: test_wm_docker 55/139 Test #55: test_wm_docker .......................... Passed 0.08 sec Start 56: test_wm_gcp 56/139 Test #56: test_wm_gcp ............................. Passed 0.03 sec Start 57: test_wmodules_gcp 57/139 Test #57: test_wmodules_gcp ....................... Passed 0.11 sec Start 58: test_wm_oscap 58/139 Test #58: test_wm_oscap ........................... Passed 0.07 sec Start 59: test_wm_sca 59/139 Test #59: test_wm_sca ............................. Passed 0.08 sec Start 60: test_wmodules_scheduling 60/139 Test #60: test_wmodules_scheduling ................ Passed 0.02 sec Start 61: test_wm_vuln_detector 61/139 Test #61: test_wm_vuln_detector ................... Passed 0.12 sec Start 62: test_wm_vuln_detector_evr 62/139 Test #62: test_wm_vuln_detector_evr ............... Passed 0.02 sec Start 63: test_wm_vuln_detector_nvd 63/139 Test #63: test_wm_vuln_detector_nvd ............... Passed 0.09 sec Start 64: test_wm_task_manager 64/139 Test #64: test_wm_task_manager .................... Passed 0.03 sec Start 65: test_wm_task_manager_parsing 65/139 Test #65: test_wm_task_manager_parsing ............ Passed 0.02 sec Start 66: test_wm_task_manager_commands 66/139 Test #66: test_wm_task_manager_commands ........... Passed 0.03 sec Start 67: test_wm_agent_upgrade 67/139 Test #67: test_wm_agent_upgrade ................... Passed 0.02 sec Start 68: test_wm_agent_upgrade_manager 68/139 Test #68: test_wm_agent_upgrade_manager ........... Passed 0.03 sec Start 69: test_wm_agent_upgrade_parsing 69/139 Test #69: test_wm_agent_upgrade_parsing ........... Passed 0.03 sec Start 70: test_wm_agent_upgrade_validate 70/139 Test #70: test_wm_agent_upgrade_validate .......... Passed 0.03 sec Start 71: test_wm_agent_upgrade_tasks 71/139 Test #71: test_wm_agent_upgrade_tasks ............. Passed 0.02 sec Start 72: test_wm_agent_upgrade_tasks_callbacks 72/139 Test #72: test_wm_agent_upgrade_tasks_callbacks ... Passed 0.03 sec Start 73: test_wm_agent_upgrade_commands 73/139 Test #73: test_wm_agent_upgrade_commands .......... Passed 0.03 sec Start 74: test_wm_agent_upgrade_upgrades 74/139 Test #74: test_wm_agent_upgrade_upgrades .......... Passed 0.04 sec Start 75: test_wm_github 75/139 Test #75: test_wm_github .......................... Passed 0.09 sec Start 76: test_wm_office365 76/139 Test #76: test_wm_office365 ....................... Passed 0.10 sec Start 77: test_monitord 77/139 Test #77: test_monitord ........................... Passed 0.03 sec Start 78: test_monitor_actions 78/139 Test #78: test_monitor_actions .................... Passed 0.08 sec Start 79: test_logcollector 79/139 Test #79: test_logcollector ....................... Passed 0.09 sec Start 80: test_read_multiline_regex 80/139 Test #80: test_read_multiline_regex ............... Passed 0.08 sec Start 81: test_localfile-config 81/139 Test #81: test_localfile-config ................... Passed 0.08 sec Start 82: test_state 82/139 Test #82: test_state .............................. Passed 0.02 sec Start 83: test_lccom 83/139 Test #83: test_lccom .............................. Passed 0.09 sec Start 84: test_macos_log 84/139 Test #84: test_macos_log .......................... Passed 0.03 sec Start 85: test_read_macos 85/139 Test #85: test_read_macos ......................... Passed 0.09 sec Start 86: test_execd 86/139 Test #86: test_execd .............................. Passed 0.08 sec Start 87: test_create_db 87/139 Test #87: test_create_db .......................... Passed 0.11 sec Start 88: test_syscom 88/139 Test #88: test_syscom ............................. Passed 0.02 sec Start 89: test_fim_diff_changes 89/139 Test #89: test_fim_diff_changes ................... Passed 0.09 sec Start 90: test_run_realtime 90/139 Test #90: test_run_realtime ....................... Passed 0.09 sec Start 91: test_syscheck_config 91/139 Test #91: test_syscheck_config .................... Passed 0.11 sec Start 92: test_syscheck 92/139 Test #92: test_syscheck ........................... Passed 0.02 sec Start 93: test_fim_sync 93/139 Test #93: test_fim_sync ........................... Passed 0.14 sec Start 94: test_run_check 94/139 Test #94: test_run_check .......................... Passed 0.15 sec Start 95: test_fim_db 95/139 Test #95: test_fim_db ............................. Passed 0.09 sec Start 96: test_fim_db_files 96/139 Test #96: test_fim_db_files ....................... Passed 0.09 sec Start 97: test_audit_healthcheck 97/139 Test #97: test_audit_healthcheck .................. Passed 0.08 sec Start 98: test_audit_rule_handling 98/139 Test #98: test_audit_rule_handling ................ Passed 0.09 sec Start 99: test_syscheck_audit 99/139 Test #99: test_syscheck_audit ..................... Passed 0.09 sec Start 100: test_audit_parse 100/139 Test #100: test_audit_parse ........................ Passed 0.10 sec Start 101: test_list_op 101/139 Test #101: test_list_op ............................ Passed 0.07 sec Start 102: test_file_op 102/139 Test #102: test_file_op ............................ Passed 0.02 sec Start 103: test_integrity_op 103/139 Test #103: test_integrity_op ....................... Passed 0.02 sec Start 104: test_rbtree_op 104/139 Test #104: test_rbtree_op .......................... Passed 0.02 sec Start 105: test_validate_op 105/139 Test #105: test_validate_op ........................ Passed 0.02 sec Start 106: test_string_op 106/139 Test #106: test_string_op .......................... Passed 0.02 sec Start 107: test_expression 107/139 Test #107: test_expression ......................... Passed 0.02 sec Start 108: test_version_op 108/139 Test #108: test_version_op ......................... Passed 0.03 sec Start 109: test_queue_op 109/139 Test #109: test_queue_op ........................... Passed 0.02 sec Start 110: test_queue_linked_op 110/139 Test #110: test_queue_linked_op .................... Passed 0.02 sec Start 111: test_agent_op 111/139 Test #111: test_agent_op ........................... Passed 0.02 sec Start 112: test_set_agent_group 112/139 Test #112: test_set_agent_group .................... Passed 0.02 sec Start 113: test_enrollment_op 113/139 Test #113: test_enrollment_op ...................... Passed 0.04 sec Start 114: test_time_op 114/139 Test #114: test_time_op ............................ Passed 0.02 sec Start 115: test_buffer_op 115/139 Test #115: test_buffer_op .......................... Passed 0.02 sec Start 116: test_utf8_op 116/139 Test #116: test_utf8_op ............................ Passed 0.02 sec Start 117: test_log_builder 117/139 Test #117: test_log_builder ........................ Passed 0.02 sec Start 118: test_custom_output_search_replace 118/139 Test #118: test_custom_output_search_replace ....... Passed 0.02 sec Start 119: test_bzip2_op 119/139 Test #119: test_bzip2_op ........................... Passed 0.01 sec Start 120: test_schedule_scan 120/139 Test #120: test_schedule_scan ...................... Passed 0.04 sec Start 121: test_rootcheck_op 121/139 Test #121: test_rootcheck_op ....................... Passed 0.04 sec Start 122: test_fs_op 122/139 Test #122: test_fs_op .............................. Passed 0.02 sec Start 123: test_wazuhdb_op 123/139 Test #123: test_wazuhdb_op ......................... Passed 0.02 sec Start 124: test_syscheck_op 124/139 Test #124: test_syscheck_op ........................ Passed 0.11 sec Start 125: test_audit_op 125/139 Test #125: test_audit_op ........................... Passed 0.02 sec Start 126: test_privsep_op 126/139 Test #126: test_privsep_op ......................... Passed 0.02 sec Start 127: test_mq_op 127/139 Test #127: test_mq_op .............................. Passed 0.02 sec Start 128: test_remoted_op 128/139 Test #128: test_remoted_op ......................... Passed 0.03 sec Start 129: test_json-queue 129/139 Test #129: test_json-queue ......................... Passed 0.02 sec Start 130: test_bqueue 130/139 Test #130: test_bqueue ............................. Passed 0.02 sec Start 131: test_atomic 131/139 Test #131: test_atomic ............................. Passed 0.02 sec Start 132: test_url 132/139 Test #132: test_url ................................ Passed 0.03 sec Start 133: test_sysinfo_utils 133/139 Test #133: test_sysinfo_utils ...................... Passed 0.02 sec Start 134: test_os_xml 134/139 Test #134: test_os_xml ............................. Passed 0.06 sec Start 135: test_os_regex 135/139 Test #135: test_os_regex ........................... Passed 0.02 sec Start 136: test_os_regex_execute 136/139 Test #136: test_os_regex_execute ................... Passed 0.04 sec Start 137: test_os_zlib 137/139 Test #137: test_os_zlib ............................ Passed 0.02 sec Start 138: test_os_net 138/139 Test #138: test_os_net ............................. Passed 0.02 sec Start 139: test_fluentd_forwarder 139/139 Test #139: test_fluentd_forwarder .................. Passed 0.02 sec 100% tests passed, 0 tests failed out of 139 Total Test time (real) = 7.01 sec ```
QU3B1M commented 2 years ago

Run CMocka unit tests for the UNIX agent.

Test Execution on master - Install the required dependencies ([the ones used here](https://github.com/wazuh/wazuh/tree/master/src/unit_tests#unit-tests)) - Download & extract wazuh master `curl -Ls https://github.com/wazuh/wazuh/archive/v4.3.6.tar.gz | tar zx` - Compile wazuh server with the _debug_ and _test_ flags `cd wazuh/src/ && make deps` `make TARGET=agent DEBUG=1 TEST=1` - Compile Unit Tests `mkdir unit_tests/build/ && cd unit_tests/build/` `cmake -DTARGET=agent ..` `make` - Execute CMOCKA Unit Tests `ctest` ```bash Test project /home/vagrant/wazuh/src/unit_tests/build Start 1: test_start_agent 1/60 Test #1: test_start_agent .................... Passed 0.04 sec Start 2: test_notify 2/60 Test #2: test_notify ......................... Passed 0.03 sec Start 3: test_agentd_state 3/60 Test #3: test_agentd_state ................... Passed 0.03 sec Start 4: test_buffer 4/60 Test #4: test_buffer ......................... Passed 0.03 sec Start 5: test_logcollector 5/60 Test #5: test_logcollector ................... Passed 0.03 sec Start 6: test_read_multiline_regex 6/60 Test #6: test_read_multiline_regex ........... Passed 0.03 sec Start 7: test_localfile-config 7/60 Test #7: test_localfile-config ............... Passed 0.03 sec Start 8: test_state 8/60 Test #8: test_state .......................... Passed 0.02 sec Start 9: test_lccom 9/60 Test #9: test_lccom .......................... Passed 0.03 sec Start 10: test_macos_log 10/60 Test #10: test_macos_log ...................... Passed 0.02 sec Start 11: test_read_macos 11/60 Test #11: test_read_macos ..................... Passed 0.03 sec Start 12: test_execd 12/60 Test #12: test_execd .......................... Passed 0.02 sec Start 13: test_wm_github 13/60 Test #13: test_wm_github ...................... Passed 0.04 sec Start 14: test_wm_office365 14/60 Test #14: test_wm_office365 ................... Passed 0.05 sec Start 15: test_create_db 15/60 Test #15: test_create_db ...................... Passed 0.05 sec Start 16: test_syscom 16/60 Test #16: test_syscom ......................... Passed 0.02 sec Start 17: test_fim_diff_changes 17/60 Test #17: test_fim_diff_changes ............... Passed 0.04 sec Start 18: test_run_realtime 18/60 Test #18: test_run_realtime ................... Passed 0.04 sec Start 19: test_syscheck_config 19/60 Test #19: test_syscheck_config ................ Passed 0.05 sec Start 20: test_syscheck 20/60 Test #20: test_syscheck ....................... Passed 0.01 sec Start 21: test_fim_sync 21/60 Test #21: test_fim_sync ....................... Passed 0.10 sec Start 22: test_run_check 22/60 Test #22: test_run_check ...................... Passed 0.09 sec Start 23: test_fim_db 23/60 Test #23: test_fim_db ......................... Passed 0.04 sec Start 24: test_fim_db_files 24/60 Test #24: test_fim_db_files ................... Passed 0.04 sec Start 25: test_audit_healthcheck 25/60 Test #25: test_audit_healthcheck .............. Passed 0.03 sec Start 26: test_audit_rule_handling 26/60 Test #26: test_audit_rule_handling ............ Passed 0.03 sec Start 27: test_syscheck_audit 27/60 Test #27: test_syscheck_audit ................. Passed 0.04 sec Start 28: test_audit_parse 28/60 Test #28: test_audit_parse .................... Passed 0.04 sec Start 29: test_list_op 29/60 Test #29: test_list_op ........................ Passed 0.03 sec Start 30: test_file_op 30/60 Test #30: test_file_op ........................ Passed 0.02 sec Start 31: test_integrity_op 31/60 Test #31: test_integrity_op ................... Passed 0.01 sec Start 32: test_rbtree_op 32/60 Test #32: test_rbtree_op ...................... Passed 0.02 sec Start 33: test_validate_op 33/60 Test #33: test_validate_op .................... Passed 0.02 sec Start 34: test_string_op 34/60 Test #34: test_string_op ...................... Passed 0.02 sec Start 35: test_expression 35/60 Test #35: test_expression ..................... Passed 0.02 sec Start 36: test_version_op 36/60 Test #36: test_version_op ..................... Passed 0.02 sec Start 37: test_queue_op 37/60 Test #37: test_queue_op ....................... Passed 0.02 sec Start 38: test_queue_linked_op 38/60 Test #38: test_queue_linked_op ................ Passed 0.02 sec Start 39: test_agent_op 39/60 Test #39: test_agent_op ....................... Passed 0.02 sec Start 40: test_enrollment_op 40/60 Test #40: test_enrollment_op .................. Passed 0.03 sec Start 41: test_time_op 41/60 Test #41: test_time_op ........................ Passed 0.01 sec Start 42: test_buffer_op 42/60 Test #42: test_buffer_op ...................... Passed 0.01 sec Start 43: test_utf8_op 43/60 Test #43: test_utf8_op ........................ Passed 0.02 sec Start 44: test_log_builder 44/60 Test #44: test_log_builder .................... Passed 0.02 sec Start 45: test_custom_output_search_replace 45/60 Test #45: test_custom_output_search_replace ... Passed 0.01 sec Start 46: test_syscheck_op 46/60 Test #46: test_syscheck_op .................... Passed 0.02 sec Start 47: test_audit_op 47/60 Test #47: test_audit_op ....................... Passed 0.01 sec Start 48: test_privsep_op 48/60 Test #48: test_privsep_op ..................... Passed 0.01 sec Start 49: test_mq_op 49/60 Test #49: test_mq_op .......................... Passed 0.02 sec Start 50: test_remoted_op 50/60 Test #50: test_remoted_op ..................... Passed 0.02 sec Start 51: test_atomic 51/60 Test #51: test_atomic ......................... Passed 0.01 sec Start 52: test_url 52/60 Test #52: test_url ............................ Passed 0.02 sec Start 53: test_sysinfo_utils 53/60 Test #53: test_sysinfo_utils .................. Passed 0.02 sec Start 54: test_os_xml 54/60 Test #54: test_os_xml ......................... Passed 0.04 sec Start 55: test_os_regex 55/60 Test #55: test_os_regex ....................... Passed 0.02 sec Start 56: test_os_regex_execute 56/60 Test #56: test_os_regex_execute ............... Passed 0.03 sec Start 57: test_os_zlib 57/60 Test #57: test_os_zlib ........................ Passed 0.02 sec Start 58: test_os_net 58/60 Test #58: test_os_net ......................... Passed 0.02 sec Start 59: test_fluentd_forwarder 59/60 Test #59: test_fluentd_forwarder .............. Passed 0.03 sec Start 60: test_active-response 60/60 Test #60: test_active-response ................ Passed 0.01 sec 100% tests passed, 0 tests failed out of 60 Total Test time (real) = 1.65 sec ```
Test Execution on branch with the FIX :green_circle: - Install the required dependencies ([the ones used here](https://github.com/wazuh/wazuh/tree/master/src/unit_tests#unit-tests)) - Clone the wazuh repo specifying the branch with the fix (`14502-logcollector-unit-test-failure`) `git clone https://github.com/wazuh/wazuh.git -b 14502-logcollector-unit-test-failure` - Compile wazuh server with the _debug_ and _test_ flags `cd wazuh/src/ && make deps` `make TARGET=agent DEBUG=1 TEST=1` - Compile Unit Tests `mkdir unit_tests/build/ && cd unit_tests/build/` `cmake -DTARGET=agent ..` `make` - Execute CMOCKA Unit Tests `ctest` ```bash Test project /home/vagrant/wazuh/src/unit_tests/build Start 1: test_start_agent 1/59 Test #1: test_start_agent .................... Passed 0.07 sec Start 2: test_notify 2/59 Test #2: test_notify ......................... Passed 0.05 sec Start 3: test_agentd_state 3/59 Test #3: test_agentd_state ................... Passed 0.05 sec Start 4: test_buffer 4/59 Test #4: test_buffer ......................... Passed 0.05 sec Start 5: test_logcollector 5/59 Test #5: test_logcollector ................... Passed 0.05 sec Start 6: test_read_multiline_regex 6/59 Test #6: test_read_multiline_regex ........... Passed 0.06 sec Start 7: test_localfile-config 7/59 Test #7: test_localfile-config ............... Passed 0.05 sec Start 8: test_state 8/59 Test #8: test_state .......................... Passed 0.02 sec Start 9: test_lccom 9/59 Test #9: test_lccom .......................... Passed 0.06 sec Start 10: test_macos_log 10/59 Test #10: test_macos_log ...................... Passed 0.03 sec Start 11: test_read_macos 11/59 Test #11: test_read_macos ..................... Passed 0.06 sec Start 12: test_execd 12/59 Test #12: test_execd .......................... Passed 0.05 sec Start 13: test_wm_github 13/59 Test #13: test_wm_github ...................... Passed 0.06 sec Start 14: test_wm_office365 14/59 Test #14: test_wm_office365 ................... Passed 0.07 sec Start 15: test_create_db 15/59 Test #15: test_create_db ...................... Passed 0.05 sec Start 16: test_syscom 16/59 Test #16: test_syscom ......................... Passed 0.02 sec Start 17: test_fim_diff_changes 17/59 Test #17: test_fim_diff_changes ............... Passed 0.03 sec Start 18: test_run_realtime 18/59 Test #18: test_run_realtime ................... Passed 0.07 sec Start 19: test_syscheck_config 19/59 Test #19: test_syscheck_config ................ Passed 0.05 sec Start 20: test_syscheck 20/59 Test #20: test_syscheck ....................... Passed 0.01 sec Start 21: test_fim_sync 21/59 Test #21: test_fim_sync ....................... Passed 0.09 sec Start 22: test_run_check 22/59 Test #22: test_run_check ...................... Passed 0.09 sec Start 23: test_fim_db 23/59 Test #23: test_fim_db ......................... Passed 0.04 sec Start 24: test_fim_db_files 24/59 Test #24: test_fim_db_files ................... Passed 0.03 sec Start 25: test_audit_healthcheck 25/59 Test #25: test_audit_healthcheck .............. Passed 0.03 sec Start 26: test_audit_rule_handling 26/59 Test #26: test_audit_rule_handling ............ Passed 0.03 sec Start 27: test_syscheck_audit 27/59 Test #27: test_syscheck_audit ................. Passed 0.04 sec Start 28: test_audit_parse 28/59 Test #28: test_audit_parse .................... Passed 0.04 sec Start 29: test_list_op 29/59 Test #29: test_list_op ........................ Passed 0.02 sec Start 30: test_file_op 30/59 Test #30: test_file_op ........................ Passed 0.01 sec Start 31: test_integrity_op 31/59 Test #31: test_integrity_op ................... Passed 0.01 sec Start 32: test_rbtree_op 32/59 Test #32: test_rbtree_op ...................... Passed 0.02 sec Start 33: test_validate_op 33/59 Test #33: test_validate_op .................... Passed 0.01 sec Start 34: test_string_op 34/59 Test #34: test_string_op ...................... Passed 0.02 sec Start 35: test_expression 35/59 Test #35: test_expression ..................... Passed 0.03 sec Start 36: test_version_op 36/59 Test #36: test_version_op ..................... Passed 0.02 sec Start 37: test_queue_op 37/59 Test #37: test_queue_op ....................... Passed 0.02 sec Start 38: test_queue_linked_op 38/59 Test #38: test_queue_linked_op ................ Passed 0.01 sec Start 39: test_agent_op 39/59 Test #39: test_agent_op ....................... Passed 0.02 sec Start 40: test_enrollment_op 40/59 Test #40: test_enrollment_op .................. Passed 0.03 sec Start 41: test_time_op 41/59 Test #41: test_time_op ........................ Passed 0.01 sec Start 42: test_buffer_op 42/59 Test #42: test_buffer_op ...................... Passed 0.01 sec Start 43: test_utf8_op 43/59 Test #43: test_utf8_op ........................ Passed 0.01 sec Start 44: test_log_builder 44/59 Test #44: test_log_builder .................... Passed 0.02 sec Start 45: test_custom_output_search_replace 45/59 Test #45: test_custom_output_search_replace ... Passed 0.01 sec Start 46: test_syscheck_op 46/59 Test #46: test_syscheck_op .................... Passed 0.02 sec Start 47: test_audit_op 47/59 Test #47: test_audit_op ....................... Passed 0.02 sec Start 48: test_privsep_op 48/59 Test #48: test_privsep_op ..................... Passed 0.01 sec Start 49: test_mq_op 49/59 Test #49: test_mq_op .......................... Passed 0.02 sec Start 50: test_remoted_op 50/59 Test #50: test_remoted_op ..................... Passed 0.02 sec Start 51: test_atomic 51/59 Test #51: test_atomic ......................... Passed 0.02 sec Start 52: test_url 52/59 Test #52: test_url ............................ Passed 0.02 sec Start 53: test_sysinfo_utils 53/59 Test #53: test_sysinfo_utils .................. Passed 0.02 sec Start 54: test_os_xml 54/59 Test #54: test_os_xml ......................... Passed 0.04 sec Start 55: test_os_regex 55/59 Test #55: test_os_regex ....................... Passed 0.02 sec Start 56: test_os_regex_execute 56/59 Test #56: test_os_regex_execute ............... Passed 0.03 sec Start 57: test_os_zlib 57/59 Test #57: test_os_zlib ........................ Passed 0.01 sec Start 58: test_os_net 58/59 Test #58: test_os_net ......................... Passed 0.01 sec Start 59: test_fluentd_forwarder 59/59 Test #59: test_fluentd_forwarder .............. Passed 0.02 sec 100% tests passed, 0 tests failed out of 59 Total Test time (real) = 1.94 sec ```
jmv74211 commented 2 years ago

Several test runs have been launched with the fix and everything has passed correctly.

1

It is also true that I have tried to reproduce the unit test failures, and I have not been able to reproduce it in about 10 builds testing with different branches and forms.

🟢 Everything seems to be working properly.