secp256k1 icon indicating copy to clipboard operation
secp256k1 copied to clipboard

Running a single test file

Open Sjors opened this issue 1 year ago • 5 comments

Similar to src/test/test_bitcoin --run-test=something I'd like to be able to run a single test file, because make check takes a while.

Maybe this is already possible, in which it just needs a README change...

Sjors avatar Jul 09 '24 12:07 Sjors

Even with --disable-exhaustive-tests it's a bit slow when e.g. you're just trying to monkey-wrench test vectors.

Sjors avatar Jul 09 '24 12:07 Sjors

./tests 4 or even ./tests 0 may help you.

real-or-random avatar Jul 09 '24 13:07 real-or-random

./tests 0 fails with An iteration count of 0 or less is not allowed..

./tests 1 takes 14 seconds for me. Doable but not as nice as ~1 second.

Sjors avatar Jul 09 '24 13:07 Sjors

PR #1211 is an attempt to implement this.

jonasnick avatar Jul 09 '24 18:07 jonasnick

Maybe this is already possible...

Yes, it is possible when using CMake:

$ cmake -B build
$ cmake --build build
$ ctest --test-dir build --show-only 
Internal ctest changing into directory: /home/hebasto/git/secp256k1/secp256k1/build
Test project /home/hebasto/git/secp256k1/secp256k1/build
  Test #1: noverify_tests
  Test #2: tests
  Test #3: exhaustive_tests

Total Tests: 3
$ ctest --test-dir build --show-only -R ^tests
Internal ctest changing into directory: /home/hebasto/git/secp256k1/secp256k1/build
Test project /home/hebasto/git/secp256k1/secp256k1/build
  Test #2: tests

Total Tests: 1

hebasto avatar Aug 12 '24 10:08 hebasto

Maybe this is already possible...

Yes, it is possible when using CMake:

What’s displayed there are the test binaries, not the individual test cases @hebasto. Each binary contains multiple test cases, and at present there’s no way to specify which one to run. #1734 introduces that capability, along with support for test execution parallelization (which in my view is quite useful, since it lets you run the full suite quite fast with just a few workers).

@Sjors, feel welcome to explore it. Self-quote from #1734: You can rapidly try it using ./tests -j=<workers_num> for parallel execution, or ./tests -t=<test_name> to run a specific test (use ./tests -print_tests to display all available tests). Or run ./tests -help to see all available options. Also, you can repeat the -t arg (or -target) to specify multiple tests at the same time.

furszy avatar Sep 05 '25 19:09 furszy