This is our first execution test (executing a util, checking the result). The intention is to introduce a very simple test for bitcoin-tx, to better gauge the needs to execution tests.
Add "it works" test for bitcoin-tx #4624
pull jgarzik wants to merge 2 commits into bitcoin:master from jgarzik:2014_bitcoin_tx_first_test changing 7 files +100 −3-
jgarzik commented at 2:19 PM on August 3, 2014: contributor
-
laanwj commented at 2:31 PM on August 3, 2014: member
Good to have tests for bitcoin-tx.
Nit: I'd prefer to use Python for the test executor. It allows doing some more advanced checks without getting a very messy shell script when processing JSON and such (the tests in qa/rpc-tests were moved to Python for this reason too).
-
jgarzik commented at 2:38 PM on August 3, 2014: contributor
@laanwj Well, two comments on that,
- The RPC tests appeared to be ultimately driven by shell scripts, which was the genesis of this direction. I suppose I could add another layer here, but I don't how you could get much more simple than this.
- For a command line util, a shell script + statically prepared data output for cmp(1) is typically all you need.
That said, I am OK with adding some prepared python test driver if you have a favorite one pre-written.
For now, a simple shell 'for' loop that (1) executes a command line and (2) compares output with statically prepared output should cover a wide range of tests with one small shell script.
-
laanwj commented at 2:54 PM on August 3, 2014: member
Well for the RPC tests we got all kinds of very subtle edge cases. Making a robust shell script that doesn't shoot you in the foot in unexpected conditions (which can be as mild as spaces in directory names) is harder then it seems. And don't forget the subtle differences between shells on different platforms. That's all a lot easier to get right with Python. Although granted, the case here is easier as there is no need to set up test nodes and kill them afterwards.
I don't insist on converting it to Python, but it would be unfortunate to have the same realizations again with yet another built-in test framework.
-
laanwj commented at 3:17 PM on August 4, 2014: member
Anyhow - ACK after this passed pulltester
- laanwj added the label Tests on Aug 6, 2014
-
theuni commented at 5:18 PM on August 15, 2014: member
After a good bit of research on this one, turns out there's a stupidly easy answer. srcdir is exported already.
diff --git a/src/test/bitcoin-tx-test.sh b/src/test/bitcoin-tx-test.sh index 5887b1c..b255e7d 100755 --- a/src/test/bitcoin-tx-test.sh +++ b/src/test/bitcoin-tx-test.sh @@ -1,7 +1,7 @@ #!/bin/sh -x TMP_FN=testcmp.$$ -BASE_FN=$TOP_SRCDIR/src/test/data/blanktx.hex +BASE_FN=$srcdir/test/data/blanktx.hex ./bitcoin-tx -create > $TMP_FN if [ $? -ne 0 ]; thenThen the env stuff can go away and we don't have to worry about automake versions.
-
laanwj commented at 7:40 AM on August 18, 2014: member
@theuni doesn't seem to work for me;
============================================= Bitcoin Core 0.9.99: src/test-suite.log ============================================= # TOTAL: 3 # PASS: 2 # SKIP: 0 # XFAIL: 0 # FAIL: 1 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 FAIL: test/bitcoin-tx-test.sh ============================= + TMP_FN=testcmp.27109 + BASE_FN=./src/test/data/blanktx.hex + ./bitcoin-tx -create + [ 0 -ne 0 ] + cmp --verbose testcmp.27109 ./src/test/data/blanktx.hex cmp: ./src/test/data/blanktx.hex: No such file or directory + RET=2 + rm -f testcmp.27109 + [ 2 -ne 0 ] + exit 1Looks like
$srcdiris relative to the root of the project, and the test is executed insrc/. -
Add "it works" test for bitcoin-tx d789386371
-
bitcoin-tx: Accept input via stdin. Add input handling to tests. fb14452c6c
-
BitcoinPullTester commented at 2:43 PM on August 19, 2014: none
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4624_fb14452c6cadb8d977c405dddb0a94115250d7c4/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
-
laanwj commented at 3:07 PM on August 19, 2014: member
ACK
- jgarzik merged this on Aug 19, 2014
- jgarzik closed this on Aug 19, 2014
- jgarzik referenced this in commit fb11427e54 on Aug 19, 2014
- jgarzik deleted the branch on Aug 24, 2014
-
rebroad commented at 6:31 AM on October 25, 2014: contributor
How do I use this? Currently Travis is complaining about a recent pull request I raised (https://travis-ci.org/bitcoin/bitcoin/jobs/38996464) and it appears to be this where the error is appearing. Is there any documentation on how to debug when it fails?
-
jgarzik commented at 12:55 PM on October 25, 2014: contributor
@rebroad Standard autoconf test suite execution, standard autoconf test documentation.
bitcoin-util-test.py executes tests from test/data/bitcoin-util-test.json.
Run "make check" and individual results will be found in *.log and *.trs files.
- MarcoFalke locked this on Sep 8, 2021