Much-improved method for configuring test-driver program: copy
test_main.h.base to test_main.h, and edit.
git-svn-id: svn://svn.valgrind.org/vex/trunk@457 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/Makefile b/Makefile
index 56333bb..d6d866c 100644
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,7 @@
ALL_HEADERS = $(PUB_HEADERS) $(PRIV_HEADERS)
ALL_INCLUDES = $(PUB_INCLUDES) $(PRIV_INCLUDES)
-test_main.o: $(PUB_HEADERS) test_main.c
+test_main.o: $(PUB_HEADERS) test_main.c test_main.h
$(CC) $(CCFLAGS) $(PUB_INCLUDES) -o test_main.o \
-c test_main.c
diff --git a/test_main.c b/test_main.c
index 33e2db1..50372ca 100644
--- a/test_main.c
+++ b/test_main.c
@@ -13,6 +13,9 @@
#include "libvex_basictypes.h"
#include "libvex.h"
+#include "test_main.h"
+
+
/*---------------------------------------------------------------*/
/*--- Test ---*/
/*---------------------------------------------------------------*/
@@ -49,7 +52,7 @@
Int i;
UInt u, sum;
Addr32 orig_addr;
- Int bb_number;
+ Int bb_number, n_bbs_done = 0;
Int orig_nbytes, trans_used, orig_used;
TranslateResult tres;
VexControl vcon;
@@ -73,59 +76,58 @@
LibVEX_Init ( &failure_exit, &log_bytes,
1, /* debug_paranoia */
- //False,
- True, /* valgrind support */
+ TEST_VSUPPORT, /* valgrind support */
&vcon );
-#if 0
- {extern void test_asm86(void);
- test_asm86();
- return 0;
- }
-#endif
while (!feof(f)) {
+
fgets(linebuf, N_LINEBUF,f);
- //printf("%s", linebuf);
- assert(linebuf[0] != 0);
+ if (linebuf[0] == 0) continue;
if (linebuf[0] != '.') continue;
+
+ if (n_bbs_done == TEST_N_BBS) break;
+ n_bbs_done++;
+
/* first line is: . bb-number bb-addr n-bytes */
assert(3 == sscanf(&linebuf[1], " %d %x %d\n",
& bb_number,
- & orig_addr, & orig_nbytes ));
+ & orig_addr, & orig_nbytes ));
assert(orig_nbytes >= 1);
assert(!feof(f));
fgets(linebuf, N_LINEBUF,f);
assert(linebuf[0] == '.');
+
/* second line is: . byte byte byte etc */
- //printf("%s", linebuf);
if (verbose)
printf("============ Basic Block %d, "
"Start %x, nbytes %2d ============",
- bb_number, orig_addr, orig_nbytes);
+ n_bbs_done-1, orig_addr, orig_nbytes);
+
assert(orig_nbytes >= 1 && orig_nbytes <= N_ORIGBUF);
for (i = 0; i < orig_nbytes; i++) {
- assert(1 == sscanf(&linebuf[2 + 3*i], "%x", &u));
- origbuf[i] = (UChar)u;
+ assert(1 == sscanf(&linebuf[2 + 3*i], "%x", &u));
+ origbuf[i] = (UChar)u;
}
- if (bb_number == 10000) break;
- {
- for (i = 0; i < 1; i++)
- tres =
- LibVEX_Translate ( InsnSetX86, InsnSetX86,
- origbuf, (Addr64)orig_addr, &orig_used,
- transbuf, N_TRANSBUF, &trans_used,
- NULL, /* instrument1 */
- NULL, /* instrument2 */
- NULL, /* tool-findhelper */
- NULL, /* access checker */
- (1<<2) );
+ for (i = 0; i < TEST_N_ITERS; i++)
+ tres
+ = LibVEX_Translate (
+ InsnSetX86, InsnSetX86,
+ origbuf, (Addr64)orig_addr, &orig_used,
+ transbuf, N_TRANSBUF, &trans_used,
+ NULL, /* instrument1 */
+ NULL, /* instrument2 */
+ NULL, /* tool-findhelper */
+ NULL, /* access checker */
+ TEST_FLAGS
+ );
+
if (tres != TransOK)
printf("\ntres = %d\n", (Int)tres);
assert(tres == TransOK);
assert(orig_used == orig_nbytes);
- }
+
sum = 0;
for (i = 0; i < trans_used; i++)
sum += (UInt)transbuf[i];
diff --git a/test_main.h.base b/test_main.h.base
new file mode 100644
index 0000000..9087629
--- /dev/null
+++ b/test_main.h.base
@@ -0,0 +1,35 @@
+
+/* Copy this file (test_main.h.in) to test_main.h, and edit */
+
+/* DEBUG RUN, ON V */
+#if 1
+#define TEST_VSUPPORT True
+#define TEST_N_ITERS 1
+#define TEST_N_BBS 1
+#define TEST_FLAGS (1<<7)
+#endif
+
+/* CHECKING RUN, ON V */
+#if 0
+#define TEST_VSUPPORT True
+#define TEST_N_ITERS 1
+#define TEST_N_BBS 100000
+#define TEST_FLAGS 0
+#endif
+
+/* PROFILING RUN, NATIVE */
+#if 0
+#define TEST_VSUPPORT False
+#define TEST_N_ITERS 100
+#define TEST_N_BBS 1000
+#define TEST_FLAGS 0
+#endif
+
+/* PROFILING RUN, REDUCED WORKLOAD */
+#if 0
+#define TEST_VSUPPORT False
+#define TEST_N_ITERS 3
+#define TEST_N_BBS 1000
+#define TEST_FLAGS 0
+#endif
+