Skip to content

Commit

Permalink
Add null return data check
Browse files Browse the repository at this point in the history
Modify check for passing fixtures

Modify fd_double_is_normal check to accept 0
  • Loading branch information
ravyu-jump authored and mjain-jump committed Jun 6, 2024
1 parent 0bcf794 commit 3670587
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
14 changes: 10 additions & 4 deletions contrib/test/run_test_vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ else
cd ../..
fi

find dump/test-vectors/instr/fixtures -type f -name '*.fix' -exec ./$OBJDIR/unit-test/test_exec_instr {} + > $LOG_PATH/test_vectors_exec 2>&1
failed=`grep -w FAIL $LOG_PATH/test_vectors_exec | wc -l`
find dump/test-vectors/instr/fixtures -type f -name '*.fix' -exec ./$OBJDIR/unit-test/test_exec_instr --log-path $LOG_PATH/test_exec_instr --log-level-stderr 4 {} +

total_tests=`find dump/test-vectors/instr/fixtures -type f -name '*.fix' | wc -l`
failed=`grep -wR FAIL $LOG_PATH | wc -l`
passed=`grep -wR OK $LOG_PATH | wc -l`

echo "Total test cases: $total_tests"
echo "Total passed: $passed"
echo "Total failed: $failed"

if [ "$failed" != "0" ]
if [ "$failed" != "0" ] || [ $passed -ne $total_tests ];
then
echo 'test vector execution failed'
grep -w FAIL $LOG_PATH/test_vectors_exec
grep -wR FAIL $LOG_PATH
echo $LOG_PATH
exit 1
else
Expand Down
10 changes: 6 additions & 4 deletions src/flamenco/runtime/tests/fd_exec_instr_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static int
fd_double_is_normal( double dbl ) {
ulong x = fd_dblbits( dbl );
int is_denorm =
( fd_dblbits_bexp( x ) == 0 ) |
( fd_dblbits_bexp( x ) == 0 ) &
( fd_dblbits_mant( x ) != 0 );
int is_inf =
( fd_dblbits_bexp( x ) == 2047 ) &
Expand Down Expand Up @@ -264,6 +264,7 @@ _context_create( fd_exec_instr_test_runner_t * runner,
txn_ctx->instr_err_idx = INT_MAX;
txn_ctx->capture_ctx = NULL;
txn_ctx->vote_accounts_pool = NULL;
txn_ctx->accounts_resize_delta = 0;

memset( txn_ctx->_txn_raw, 0, sizeof(fd_rawtxn_b_t) );
memset( txn_ctx->return_data.program_id.key, 0, sizeof(fd_pubkey_t) );
Expand Down Expand Up @@ -701,12 +702,13 @@ _diff_effects( fd_exec_instr_fixture_diff_t * check ) {
}

/* Check return data */
if (expected->return_data->size != ctx->txn_ctx->return_data.len) {
ulong data_sz = expected->return_data ? expected->return_data->size : 0UL; /* support expected->return_data==NULL */
if ( data_sz != ctx->txn_ctx->return_data.len ) {
check->has_diff = 1;
REPORTV( WARNING, "expected return data size %lu, got %lu",
(ulong) expected->return_data->size, ctx->txn_ctx->return_data.len );
(ulong) data_sz, ctx->txn_ctx->return_data.len );
}
else if (expected->return_data->size > 0 ) {
else if ( data_sz > 0 ) {
check->has_diff = memcmp( expected->return_data->bytes, ctx->txn_ctx->return_data.data, expected->return_data->size );
REPORT( WARNING, "return data mismatch" );
}
Expand Down

0 comments on commit 3670587

Please sign in to comment.