Hello Guys i am trying to run the tests on window...
# general
p
Hello Guys i am trying to run the tests on windows, the PS console was launched with "Run as Admin" the following test fails, even without any changes from myside. 30 - osquery_config_tests-test (Failed)
C:\Osquery\osquery\osquery\config\tests\config_tests.cpp(437): error: Expected equality of these values:
"dfae832a62a3e3a51760334184364b7d66468ccc"
source_hash
Which is: "6ff053778a90c48ed3dc2d48ffb0aca263db620a"
E20240116 21:47:43.806187 18420 config.cpp:879] updateSource failed to parse config, of source: awesome and content:
[  FAILED  ] ConfigTests.test_content_update (1131 ms)
76 - tools_tests_testosqueryd (Failed)
Directory: C:/Osquery/osquery/build/tools/tests
"tools_tests_testosqueryd" start time: Jan 17 18:30 India Standard Time
Output:
----------------------------------------------------------
Traceback (most recent call last):
File "C:\Osquery\osquery\build\tools\tests\test_osqueryd.py", line 19, in <module>
import test_base
File "C:\Osquery\osquery\build\tools\tests\test_base.py", line 13, in <module>
import psutil
ModuleNotFoundError: No module named 'psutil'
77 - tools_tests_testosqueryi (Failed) same reason as above 78 - tools_tests_testrelease (Failed) 79 - tests_integration_tables-test (Failed)
W20240117 18:30:57.449311 11676 virtual_table.cpp:971] The vscode_extensions table returns data based on the current user by default, consider JOINing against the users table
I20240117 18:30:57.476215 11676 vscode_extensions.cpp:31] Could not read vscode extensions.json from C:\Users\XXXname\.vscode-server\extensions\extensions.json
please let me know, if i can raise a PR for an issue that i am fixing, it looks like these are envoirnment issues on my PC . Appreciate any pointers or hints on these issue. thank you for looking into this. Regards Pradish
s
For the python tests, you need to install some additional packages to get them to work properly: https://osquery.readthedocs.io/en/latest/development/building/#optional-install-python-tests-prerequisites
For the
vscode_extensions
table, I don't think that's the entire issue (or even the issue that caused the failure); I suspect that the file doesn't exist and we are printing a log line, which in hindsight should've probably been a verbose log, since we are not necessarily sure that there is even vscode installed
🙌 1
The log of
tests_integration_tables-test
should show at the end which specific test case failed, and in the test case it should show which assert/check failed
For the
vscode_extensions
table I totally forgot I did not already merge a fix for an issue I've found in the test. This should fix it: https://github.com/osquery/osquery/pull/8236
🙌 1
p
Thanks Stefano for the fix and now all test cases except for one (#30) all are passing. 30 - osquery_config_tests-test (Failed)
C:\Osquery\osquery\osquery\config\tests\config_tests.cpp(437): error: Expected equality of these values:
"dfae832a62a3e3a51760334184364b7d66468ccc"
source_hash
Which is: *"6ff053778a90c48ed3dc2d48ffb0aca263db620a"*
E20240116 21:47:43.806187 18420 config.cpp:879] updateSource failed to parse config, of source: awesome and content:
[  FAILED  ] ConfigTests.test_content_update (1131 ms)
The above test case is failing because it is comparing the two hash values and they are not equal. For test case #78 i had to make two changes to the base version to make this work. 1. Add the Dumpbin path to the env variables 2. in the file test_release.py located at \osquery\build\tools\tests at line 127 the executable path is mentioned as (BUILD_DIR + "/osquery/osqueryd.exe") but the exe is not located here, it is located at osquery/RelWithDebInfo/osqueryd.exe post these two changes, the test case #78 also passed. please let me know, if i need to commit this change or is it is left to the developer to make these changes depending on their build configuration. regards Pradish
s
For the test_release.py script, that has been written for the CI first, which uses Ninja; seems you used msbuild to build. I think a proper change would be then to detect which generator is used in CMake, pass the correct parent folder path via the
--build_dir
flag, remove the
osquery
prefix in the python script, and maybe rename the
BUILD_DIR
variable to osquery dir.
As for the hash not being the same, that's strange, given that the CI passes. It would be worth understanding why it's different
👀 1
oh actually, another thing for the dumpbin path, I see that's because again to make Ninja work, you already have to call the visual studio provided .bat files which setup the env vars to let you find the compiler and other tooling in the PATH
👍 1
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ <http://steps.vc|steps.vc>_<http://arch.outputs.VC|arch.outputs.VC>_ARCH }}
👍 1
We don't use msbuild as much because it's slower to build osquery and generates longer filesystem paths, which cause issues.