Title
#windows
n

Nithin Sade

05/11/2021, 3:18 AM
Hi Folks, tl;dr I am new here and I am wondering if the current master branch is expected to fail tests. I am currently working on adding a few tables but before doing anything, I thought I'd run unit tests on the master branch. I believe only 1% of the tests are passing. Am I doing something wrong here?
theopolis

theopolis

05/11/2021, 1:02 PM
It looks like you did not build the tests. How did you run CMake?
1:03 PM
It’s subtle but important to add the configure option mentioned in the testing section here https://osquery.readthedocs.io/en/latest/development/building/
Stefano Bonicatti

Stefano Bonicatti

05/11/2021, 2:33 PM
By the way, one thing that we could do to make it more obvious maybe is to put all
add_test
directives behind the check of the tests being enabled or not. In that case then it won’t attempt to run anything because there’s no test enabled. It’s only a tad more verbose in CMake code to do.
theopolis

theopolis

05/11/2021, 3:03 PM
That's a good idea. I wonder if we could hack together a warning "You are trying to run tests but you did not build with testing support."
n

Nithin Sade

05/11/2021, 5:10 PM
Thanks for the quick response. Oh so I basically should use this‘cmake -G "Visual Studio 16 2019" -A x64 .. -DOSQUERY_BUILD_TESTS=ON’ to be able to run the tests. Will give this a try now!
3:01 AM
Got a chance to run it. Was able to pass all the tests except 49 - osquery_filesystem_filesystemtests-test & 64 - plugins_config_parsers_tests_filepathstests-test I am also attaching the respective test logs.
Stefano Bonicatti

Stefano Bonicatti

05/12/2021, 3:20 PM
@theopolis That’s unfortunately an annoying thing of CMake ahah. The
test
target is a pseudo target, meaning that you can pass it as such in the
cmake --target
command or any ninja/make command, but it’s not seen as such in CMake code. Also on Windows with msbuild that is
run_tests
. One way I’ve seen it done is to create a custom target/custom command that launches
cmake --build . --target test
and then you can have any command before or after that.. the problem with that is that on Windows with msbuild, 90% of the time you cannot interrupt the tests with a Ctrl+C… and that’s rather annoying.