|
From: <sv...@va...> - 2012-11-16 19:41:31
|
carll 2012-11-16 19:41:21 +0000 (Fri, 16 Nov 2012)
New Revision: 13124
Log:
vbit-tester, add counts for the number of 1, 2, 3 and 4 operand tests.
This patch adds code to count the number of each type of test. The
number of 1, 2, 3 and 4 operand tests that are generated by the vbit-tester
are counted and printed by the vbit-tester. The user should refer to the
Valgrind output to see if any of the tests failed.
The existing two verbose levels was increased by one level and the the
new output giving the number of tests was inserted as the first verbose
level. The verbose levels are now:
-v shows the number of 1, 2, 3 and 4 operand tests that are generated
-v -v shows IROps being tested
-v -v -v extreme edition, shows input values
This patch is for bugzilla 309229
Modified files:
trunk/memcheck/tests/vbit-test/binary.c
trunk/memcheck/tests/vbit-test/main.c
trunk/memcheck/tests/vbit-test/qernary.c
trunk/memcheck/tests/vbit-test/ternary.c
trunk/memcheck/tests/vbit-test/unary.c
trunk/memcheck/tests/vbit-test/valgrind.c
trunk/memcheck/tests/vbit-test/vtest.h
Modified: trunk/memcheck/tests/vbit-test/binary.c (+29 -11)
===================================================================
--- trunk/memcheck/tests/vbit-test/binary.c 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/binary.c 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -172,11 +172,12 @@
}
-static void
+static int
test_shift(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, i;
opnd_t *opnds = data->opnds;
+ int tests_done = 0;
/* When testing the 1st operand's undefinedness propagation,
do so with all possible shift amnounts */
@@ -193,13 +194,14 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
}
// 2nd (right) operand
/* If the operand is an immediate value, there are no v-bits to set. */
- if (op->shift_amount_is_immediate) return;
+ if (op->shift_amount_is_immediate) return tests_done;
num_input_bits = bitsof_irtype(opnds[1].type);
@@ -210,7 +212,10 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+
+ tests_done++;
}
+ return tests_done;
}
@@ -248,11 +253,12 @@
}
-static void
+static int
test_and(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, bitpos;
opnd_t *opnds = data->opnds;
+ int tests_done = 0;
/* Undefinedness does not propagate if the other operand is 0.
Use an all-bits-zero operand and test the other operand in
@@ -269,6 +275,7 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
// 2nd (right) operand variable, 1st operand all-bits-zero
@@ -282,6 +289,7 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
/* Undefinedness propagates if the other operand is 1.
@@ -299,6 +307,7 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
// 2nd (right) operand variable, 1st operand all-bits-one
@@ -312,15 +321,18 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
+ return tests_done;
}
-static void
+static int
test_or(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, bitpos;
opnd_t *opnds = data->opnds;
+ int tests_done = 0;
/* Undefinedness does not propagate if the other operand is 1.
Use an all-bits-one operand and test the other operand in
@@ -339,6 +351,7 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
// 2nd (right) operand variable, 1st operand all-bits-one
@@ -354,6 +367,7 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
/* Undefinedness propagates if the other operand is 0.
@@ -373,6 +387,7 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
// 2nd (right) operand variable, 1st operand all-bits-zero
@@ -388,31 +403,31 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+ tests_done++;
}
+ return tests_done;
}
-void
+int
test_binary_op(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, i, bitpos;
opnd_t *opnds = data->opnds;
+ int tests_done = 0;
/* Handle special cases upfront */
switch (op->undef_kind) {
case UNDEF_SHL:
case UNDEF_SHR:
case UNDEF_SAR:
- test_shift(op, data);
- return;
+ return test_shift(op, data);
case UNDEF_AND:
- test_and(op, data);
- return;
+ return test_and(op, data);
case UNDEF_OR:
- test_or(op, data);
- return;
+ return test_or(op, data);
default:
break;
@@ -446,6 +461,9 @@
valgrind_execute_test(op, data);
check_result_for_binary(op, data);
+
+ tests_done++;
}
}
+ return tests_done;
}
Modified: trunk/memcheck/tests/vbit-test/ternary.c (+4 -1)
===================================================================
--- trunk/memcheck/tests/vbit-test/ternary.c 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/ternary.c 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -35,11 +35,12 @@
}
-void
+int
test_ternary_op(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, i, bitpos;
opnd_t *opnds = data->opnds;
+ int tests_done = 0;
/* For each operand, set a single bit to undefined and observe how
that propagates to the output. Do this for all bits in each
@@ -57,6 +58,8 @@
valgrind_execute_test(op, data);
check_result_for_ternary(op, data);
+
+ tests_done++;
}
}
}
Modified: trunk/memcheck/tests/vbit-test/valgrind.c (+3 -3)
===================================================================
--- trunk/memcheck/tests/vbit-test/valgrind.c 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/valgrind.c 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -93,12 +93,12 @@
{
unsigned i, num_operands;
- if (verbose > 1) printf("---------- Running a test\n");
+ if (verbose > 2) printf("---------- Running a test\n");
num_operands = get_num_operands(op->op);
for (i = 0; i < num_operands; ++i) {
valgrind_set_vbits(&data->opnds[i]);
- if (verbose > 1) {
+ if (verbose > 2) {
printf("opnd #%u: ", i);
print_opnd(stdout, &data->opnds[i]);
printf("\n");
@@ -106,7 +106,7 @@
}
valgrind_vex_inject_ir();
valgrind_get_vbits(&data->result);
- if (verbose > 1) {
+ if (verbose > 2) {
printf("result: ");
print_opnd(stdout, &data->result);
printf("\n");
Modified: trunk/memcheck/tests/vbit-test/unary.c (+4 -1)
===================================================================
--- trunk/memcheck/tests/vbit-test/unary.c 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/unary.c 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -53,10 +53,11 @@
}
-void
+int
test_unary_op(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, bitpos;
+ int tests_done = 0;
num_input_bits = bitsof_irtype(data->opnds[0].type);
@@ -66,5 +67,7 @@
valgrind_execute_test(op, data);
check_result_for_unary(op, data);
+ tests_done++;
}
+ return tests_done;
}
Modified: trunk/memcheck/tests/vbit-test/vtest.h (+4 -4)
===================================================================
--- trunk/memcheck/tests/vbit-test/vtest.h 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/vtest.h 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -104,10 +104,10 @@
void print_opnd(FILE *, const opnd_t *);
-void test_unary_op(const irop_t *, test_data_t *);
-void test_binary_op(const irop_t *, test_data_t *);
-void test_ternary_op(const irop_t *, test_data_t *);
-void test_qernary_op(const irop_t *, test_data_t *);
+int test_unary_op(const irop_t *, test_data_t *);
+int test_binary_op(const irop_t *, test_data_t *);
+int test_ternary_op(const irop_t *, test_data_t *);
+int test_qernary_op(const irop_t *, test_data_t *);
void valgrind_vex_init_for_iri(IRICB *);
void valgrind_execute_test(const irop_t *, test_data_t *);
Modified: trunk/memcheck/tests/vbit-test/qernary.c (+5 -1)
===================================================================
--- trunk/memcheck/tests/vbit-test/qernary.c 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/qernary.c 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -36,11 +36,12 @@
}
-void
+int
test_qernary_op(const irop_t *op, test_data_t *data)
{
unsigned num_input_bits, i, bitpos;
opnd_t *opnds = data->opnds;
+ int tests_done = 0;
/* For each operand, set a single bit to undefined and observe how
that propagates to the output. Do this for all bits in each
@@ -59,6 +60,9 @@
valgrind_execute_test(op, data);
check_result_for_qernary(op, data);
+
+ tests_done++;
}
}
+ return tests_done;
}
Modified: trunk/memcheck/tests/vbit-test/main.c (+14 -7)
===================================================================
--- trunk/memcheck/tests/vbit-test/main.c 2012-11-16 18:58:08 +00:00 (rev 13123)
+++ trunk/memcheck/tests/vbit-test/main.c 2012-11-16 19:41:21 +00:00 (rev 13124)
@@ -68,13 +68,16 @@
main(int argc, char *argv[])
{
assert(sizeof(long long) == 8);
+ int num_unary_tests = 0, num_binary_tests = 0;
+ int num_ternary_tests = 0, num_qernary_tests = 0;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-v") == 0) ++verbose;
else if (strcmp(argv[i], "--help") == 0) {
printf("\nvbit-test [ -v | --help ]\n");
- printf("\n\t-v verbose mode; shows IROps being tested\n");
- printf("\n\t-v -v verbose mode, extreme edition\n\n");
+ printf("\n\t-v verbose mode; show number of 1, 2, 3 and 4 operand tests\n");
+ printf("\n\t-v -v verbose mode; shows IROps being tested\n");
+ printf("\n\t-v -v -v verbose mode, extreme edition\n\n");
return 0;
} else {
printf("%s ? Nothing happens.\n", argv[i]);
@@ -117,7 +120,7 @@
continue;
}
- if (verbose) printf("Testing operator %s\n", op->name);
+ if (verbose > 1) printf("Testing operator %s\n", op->name);
IRICB iricb = new_iricb(op, data);
@@ -125,19 +128,19 @@
switch (iricb.num_operands) {
case 1:
- test_unary_op(op, data);
+ num_unary_tests += test_unary_op(op, data);
break;
case 2:
- test_binary_op(op, data);
+ num_binary_tests += test_binary_op(op, data);
break;
case 3:
- test_ternary_op(op, data);
+ num_ternary_tests += test_ternary_op(op, data);
break;
case 4:
- test_qernary_op(op, data);
+ num_qernary_tests += test_qernary_op(op, data);
break;
default:
@@ -147,5 +150,9 @@
free(data);
}
+ if (verbose)
+ printf("\nvbit-test ran %d unary, %d binary, %d ternary and %d qernary tests.\n",
+ num_unary_tests, num_binary_tests, num_ternary_tests,
+ num_qernary_tests);
return 0;
}
|