Fix numeric parsing.

Fix dedupe bug introduced in last commit.
Reset valid flag when resetting dedupe context.
Cleanup test suites.
Do not abort test suite on failure of a test case.
This commit is contained in:
Moinak Ghosh 2013-01-03 00:27:18 +05:30
parent 6b756eb165
commit d9eb82e0e8
12 changed files with 52 additions and 63 deletions

5
main.c
View file

@ -1163,7 +1163,6 @@ redo:
compressed_chunk = tdat->compressed_chunk + CHUNK_FLAG_SZ; compressed_chunk = tdat->compressed_chunk + CHUNK_FLAG_SZ;
rbytes = tdat->rbytes; rbytes = tdat->rbytes;
dedupe_index_sz = 0; dedupe_index_sz = 0;
tdat->rctx->valid = 0;
/* Perform Dedup if enabled. */ /* Perform Dedup if enabled. */
if ((enable_rabin_scan || enable_fixed_scan)) { if ((enable_rabin_scan || enable_fixed_scan)) {
@ -2147,9 +2146,9 @@ main(int argc, char *argv[])
case 's': case 's':
ovr = parse_numeric(&chunksize, optarg); ovr = parse_numeric(&chunksize, optarg);
if (ovr == 1) if (ovr == 1)
err_exit(0, "Chunk size too large %s", optarg); err_exit(0, "Chunk size too large %s\n", optarg);
else if (ovr == 2) else if (ovr == 2)
err_exit(0, "Invalid number %s", optarg); err_exit(0, "Invalid number %s\n", optarg);
if (chunksize < MIN_CHUNK) { if (chunksize < MIN_CHUNK) {
err_exit(0, "Minimum chunk size is %ld\n", MIN_CHUNK); err_exit(0, "Minimum chunk size is %ld\n", MIN_CHUNK);

View file

@ -258,6 +258,7 @@ reset_dedupe_context(dedupe_context_t *ctx)
{ {
memset(ctx->current_window_data, 0, RAB_POLYNOMIAL_WIN_SIZE); memset(ctx->current_window_data, 0, RAB_POLYNOMIAL_WIN_SIZE);
ctx->window_pos = 0; ctx->window_pos = 0;
ctx->valid = 0;
} }
void void

View file

@ -24,7 +24,8 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Compression failed." echo "FATAL: Compression failed."
exit 1 rm -f ${tf}.pz
continue
fi fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1" cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd" echo "Running $cmd"
@ -32,13 +33,13 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression failed." echo "FATAL: Decompression failed."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -17,7 +17,8 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Compression failed." echo "FATAL: Compression failed."
exit 1 rm -f ${tf}.pz
continue
fi fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1" cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd" echo "Running $cmd"
@ -25,14 +26,14 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression failed." echo "FATAL: Decompression failed."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -29,7 +29,7 @@ do
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: ${cmd} errored." echo "FATAL: ${cmd} errored. Cannot continue this test suite."
exit 1 exit 1
fi fi
mv ${tf}.pz ${tf}.${algo} mv ${tf}.pz ${tf}.${algo}
@ -54,8 +54,9 @@ do
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd} errored." echo "FATAL: Compression errored."
exit 1 rm -f ${tf}.${algo}.pz
continue
fi fi
cmd="../../pcompress -d ${tf}.${algo}.pz ${tf}.${algo}.1" cmd="../../pcompress -d ${tf}.${algo}.pz ${tf}.${algo}.1"
echo "Running $cmd" echo "Running $cmd"
@ -63,13 +64,13 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression failed." echo "FATAL: Decompression failed."
exit 1 rm -f ${tf}.${algo}.pz ${tf}.${algo}.1
continue
fi fi
diff ${tf}.${algo} ${tf}.${algo}.1 > /dev/null diff ${tf}.${algo} ${tf}.${algo}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
rm -f ${tf}.${algo}.pz ${tf}.${algo}.1 rm -f ${tf}.${algo}.pz ${tf}.${algo}.1
done done

View file

@ -19,23 +19,24 @@ do
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd} errored." echo "FATAL: Compression errored."
exit 1 rm -f ${tf}.pz
continue
fi fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1" cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd" echo "Running $cmd"
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd} errored." echo "FATAL: Decompression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -20,15 +20,15 @@ do
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd} errored." echo "FATAL: Compression errored."
exit 1 rm -f ${tf}.pz
continue
fi fi
pw=`cat /tmp/pwf` pw=`cat /tmp/pwf`
if [ "$pw" = "sillypassword" ] if [ "$pw" = "sillypassword" ]
then then
echo "FATAL: Password file /tmp/pwf not zeroed!" echo "FATAL: Password file /tmp/pwf not zeroed!"
exit 1
fi fi
echo "sillypassword" > /tmp/pwf echo "sillypassword" > /tmp/pwf
@ -37,22 +37,23 @@ do
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd} errored." echo "FATAL: Decompression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd}: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
pw=`cat /tmp/pwf` pw=`cat /tmp/pwf`
if [ "$pw" = "sillypassword" ] if [ "$pw" = "sillypassword" ]
then then
echo "FATAL: Password file /tmp/pwf not zeroed!" echo "FATAL: Password file /tmp/pwf not zeroed!"
exit 1
fi fi
# #
@ -66,7 +67,6 @@ do
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "FATAL: Decompression did not fail where expected." echo "FATAL: Decompression did not fail where expected."
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -23,7 +23,8 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Compression errored." echo "FATAL: Compression errored."
exit 1 rm -f ${tf}.pz
continue
fi fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1" cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd" echo "Running $cmd"
@ -31,13 +32,13 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression errored." echo "FATAL: Decompression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -23,14 +23,14 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Compression errored." echo "FATAL: Compression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
pw=`cat /tmp/pwf` pw=`cat /tmp/pwf`
if [ "$pw" = "sillypassword" ] if [ "$pw" = "sillypassword" ]
then then
echo "FATAL: Password file /tmp/pwf not zeroed!" echo "FATAL: Password file /tmp/pwf not zeroed!"
exit 1
fi fi
echo "sillypassword" > /tmp/pwf echo "sillypassword" > /tmp/pwf
@ -40,21 +40,20 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression errored." echo "FATAL: Decompression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
pw=`cat /tmp/pwf` pw=`cat /tmp/pwf`
if [ "$pw" = "sillypassword" ] if [ "$pw" = "sillypassword" ]
then then
echo "FATAL: Password file /tmp/pwf not zeroed!" echo "FATAL: Password file /tmp/pwf not zeroed!"
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -21,8 +21,9 @@ do
eval $cmd eval $cmd
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "${cmd} errored." echo "FATAL: Compression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1" cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd" echo "Running $cmd"
@ -30,14 +31,14 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression errored." echo "FATAL: Decompression errored."
exit 1 rm -f ${tf}.pz ${tf}.1
continue
fi fi
diff ${tf} ${tf}.1 > /dev/null diff ${tf} ${tf}.1 > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Decompression was not correct" echo "FATAL: Decompression was not correct"
exit 1
fi fi
rm -f ${tf}.pz ${tf}.1 rm -f ${tf}.pz ${tf}.1
done done

View file

@ -30,7 +30,6 @@ do
then then
echo "FATAL: Compression DID NOT ERROR where expected" echo "FATAL: Compression DID NOT ERROR where expected"
rm -f ${tstf}.pz rm -f ${tstf}.pz
exit 1
fi fi
rm -f ${tstf}.pz rm -f ${tstf}.pz
break break
@ -47,7 +46,6 @@ do
then then
echo "FATAL: Compression DID NOT ERROR where expected" echo "FATAL: Compression DID NOT ERROR where expected"
rm -f ${tstf}.pz rm -f ${tstf}.pz
exit 1
fi fi
rm -f ${tstf}.pz rm -f ${tstf}.pz
break break
@ -67,7 +65,7 @@ do
rm -f ${tstf}.pz rm -f ${tstf}.pz
d=`dirname ${tstf}` d=`dirname ${tstf}`
rm -f ${d}/.pc* rm -f ${d}/.pc*
exit 1 continue
fi fi
echo "Corrupting file header ..." echo "Corrupting file header ..."
@ -77,9 +75,6 @@ do
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "FATAL: Decompression DID NOT ERROR where expected." echo "FATAL: Decompression DID NOT ERROR where expected."
rm -f ${tstf}.pz
rm -f ${tstf}.1
exit 1
fi fi
rm -f ${tstf}.pz rm -f ${tstf}.pz
@ -91,8 +86,8 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Compression errored." echo "FATAL: Compression errored."
rm -f ${tstf}.pz rm -f ${tstf}.pz ${tstf}.1
exit 1 continue
fi fi
cp ${tstf}.pz ${tstf}.1.pz cp ${tstf}.pz ${tstf}.1.pz
@ -104,9 +99,6 @@ do
then then
echo "FATAL: Decompression DID NOT ERROR where expected." echo "FATAL: Decompression DID NOT ERROR where expected."
rm -f ${tstf}.pz rm -f ${tstf}.pz
rm -f ${tstf}.1
rm -f ${tstf}.1.pz
exit 1
fi fi
rm -f ${tstf}.1 rm -f ${tstf}.1
@ -121,7 +113,6 @@ do
rm -f ${tstf}.pz rm -f ${tstf}.pz
rm -f ${tstf}.1 rm -f ${tstf}.1
rm -f ${tstf}.1.pz rm -f ${tstf}.1.pz
exit 1
fi fi
rm -f ${tstf}.1 ${tstf}.1.pz ${tstf}.pz rm -f ${tstf}.1 ${tstf}.1.pz ${tstf}.pz
@ -132,15 +123,14 @@ do
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "FATAL: Compression errored." echo "FATAL: Compression errored."
rm -f ${tstf}.pz rm -f ${tstf}.pz ${tstf}.1
exit 1 continue
fi fi
pw=`cat /tmp/pwf` pw=`cat /tmp/pwf`
if [ "$pw" = "plainpasswd" ] if [ "$pw" = "plainpasswd" ]
then then
echo "FATAL: Password file was not zeroed" echo "FATAL: Password file was not zeroed"
rm -f /tmp/pwf ${tstf}.pz rm -f /tmp/pwf
exit 1
fi fi
cp ${tstf}.pz ${tstf}.1.pz cp ${tstf}.pz ${tstf}.1.pz
@ -154,8 +144,6 @@ do
echo "FATAL: Decompression DID NOT ERROR where expected." echo "FATAL: Decompression DID NOT ERROR where expected."
rm -f ${tstf}.pz rm -f ${tstf}.pz
rm -f ${tstf}.1 rm -f ${tstf}.1
rm -f ${tstf}.1.pz
exit 1
fi fi
cp ${tstf}.1.pz ${tstf}.pz cp ${tstf}.1.pz ${tstf}.pz
@ -168,10 +156,6 @@ do
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo "FATAL: Decompression DID NOT ERROR where expected." echo "FATAL: Decompression DID NOT ERROR where expected."
rm -f ${tstf}.pz
rm -f ${tstf}.1
rm -f ${tstf}.1.pz
exit 1
fi fi
done done

View file

@ -117,7 +117,7 @@ raise_by_multiplier(int64_t *val, int mult, int power) {
int int
parse_numeric(int64_t *val, const char *str) parse_numeric(int64_t *val, const char *str)
{ {
int ovr = 2; int ovr = 0;
char *mult; char *mult;
*val = strtoll(str, &mult, 0); *val = strtoll(str, &mult, 0);