Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ file(WRITE VERSION
"TLSH version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} ${TLSH_HASH}, ${TLSH_CHECKSUM}\n")

file(REMOVE include/version.h)
file(WRITE include/version.h
file(WRITE include/tlsh_version.h
"/****************************************************\n"
" * This file is generated by cmake. Modify the top\n"
" * level CMakeLists.txt to change the VERSION numbers\n"
Expand All @@ -115,7 +115,7 @@ file(WRITE include/version.h
"#define TLSH_HASH \"${TLSH_HASH}\"\n"
"#define TLSH_CHECKSUM \"${TLSH_CHECKSUM}\"\n")
if(TLSH_DISTANCE_PARAMETERS EQUAL 1)
file(APPEND include/version.h
file(APPEND include/tlsh_version.h
"#define TLSH_DISTANCE_PARAMETERS ${TLSH_DISTANCE_PARAMETERS}\n")
endif()

Expand Down
2 changes: 1 addition & 1 deletion Testing/destroy_refresh_exp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

if test "$1" = "-xlen"
then
Expand Down
20 changes: 7 additions & 13 deletions Testing/python_test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
#!/bin/sh

echoerr() { echo "$@" 1>&2; }

BASEDIR=$(dirname $0)
pushd $BASEDIR > /dev/null
cd $BASEDIR
TMP="tmp"
PYTHON=$1

Expand Down Expand Up @@ -38,8 +38,7 @@ echo "diff $TMP/python_test.out exp/python_test_EXP"
diff $TMP/python_test.out exp/python_test_EXP > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: diff $TMP/python_test.out exp/python_test_EXP"
popd > /dev/null
exit -1
exit 255
fi
echo "pass"
echo
Expand All @@ -52,8 +51,7 @@ for file in small small2 ; do
diff $TMP/py_$file.tlsh exp/$file.128.1.tlsh_EXP
if [ $? -ne 0 ]; then
echoerr "error: diff $TMP/py_$file.tlsh exp/$file.128.1.tlsh_EXP"
popd > /dev/null
exit -1
exit 255
fi

echo "${PYTHON} ../py_ext/tlsh_digest.py -old example_data/$file.txt > $TMP/py_$file.old.tlsh"
Expand All @@ -62,8 +60,7 @@ for file in small small2 ; do
diff $TMP/py_$file.old.tlsh exp/$file.128.1.old.tlsh_EXP
if [ $? -ne 0 ]; then
echoerr "error: diff $TMP/py_$file.old.tlsh exp/$file.128.1.old.tlsh_EXP"
popd > /dev/null
exit -1
exit 255
fi

echo "${PYTHON} ../py_ext/tlsh_digest.py -conservative example_data/$file.txt > $TMP/py_$file.cons.tlsh"
Expand All @@ -72,8 +69,7 @@ for file in small small2 ; do
diff $TMP/py_$file.cons.tlsh exp/$file.128.1.cons.tlsh_EXP
if [ $? -ne 0 ]; then
echoerr "error: diff $TMP/py_$file.cons.tlsh exp/$file.128.1.cons.tlsh_EXP"
popd > /dev/null
exit -1
exit 255
fi
done

Expand All @@ -86,8 +82,7 @@ echo "diff $TMP/python_parts_test.out exp/python_parts_test_EXP"
diff $TMP/python_parts_test.out exp/python_parts_test_EXP > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: diff $TMP/python_parts_test.out exp/python_parts_test_EXP"
popd > /dev/null
exit -1
exit 255
fi
echo "pass"

Expand All @@ -96,4 +91,3 @@ echo "passed"
echo
### echo "Note that if py_ext/tlshmodule.cpp has changed, then 'python setup.py build; sudo python setup.py install' must be run"

popd > /dev/null
39 changes: 3 additions & 36 deletions Testing/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

##################################
# set CREATE_EXP_FILE=1 if you want this script to create the Expected Results for the regression tests
Expand All @@ -8,7 +8,7 @@ CREATE_EXP_FILE=0
echoerr() { echo "$@" 1>&2; }

BASEDIR=$(dirname $0)
pushd $BASEDIR > /dev/null
cd $BASEDIR

LISTOPTION=1
JSONOPTION=1
Expand All @@ -34,14 +34,12 @@ echo "TLSH_PROG=$TLSH_PROG"
if test ! -f $TLSH_PROG
then
echoerr "error: (127), you must compile $TLSH_PROG"
popd > /dev/null
exit 127
fi

if test ! -f $SIMP_PROG
then
echoerr "error: (127), you must compile $SIMP_PROG"
popd > /dev/null
exit 127
fi

Expand Down Expand Up @@ -104,7 +102,6 @@ runit() {
if test ! -f $TMP/example_data.out
then
echoerr "error: (1), $TMP/example_data.out does not exist"
popd > /dev/null
exit 1
fi
EXPECTED_OUT=exp/example_data.$HASH.$CHKSUM.$XLEN.out_EXP
Expand All @@ -114,7 +111,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: (1), Expected Result file $EXPECTED_OUT does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.out $EXPECTED_OUT"
Expand All @@ -126,7 +122,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.err $EXPECTED_ERR"
Expand All @@ -137,15 +132,13 @@ runit() {
if test ! $diffc = 0
then
echoerr "error: (1), diff $TMP/example_data.out $EXPECTED_OUT"
popd > /dev/null
exit 1
fi

diffc=`diff --ignore-all-space $TMP/example_data.err $EXPECTED_ERR | wc -l`
if test ! $diffc = 0
then
echoerr "error: (1), diff $TMP/example_data.err $EXPECTED_ERR"
popd > /dev/null
exit 1
fi

Expand All @@ -160,7 +153,6 @@ runit() {
if test ! $diffc = 0
then
echoerr "error: (1), diff $TMP/example_data.json_out $EXPECTED_OUT"
popd > /dev/null
exit 1
fi
echo "passed"
Expand Down Expand Up @@ -194,7 +186,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: (1), Expected Result file $EXPECTED_SCO does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.scores $EXPECTED_SCO"
Expand All @@ -206,7 +197,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.err2 $EXPECTED_ERR"
Expand All @@ -218,14 +208,12 @@ runit() {
if test ! $diffc = 0
then
echoerr "error: (2), diff $TMP/example_data.scores $EXPECTED_SCO"
popd > /dev/null
exit 2
fi
diffc=`diff --ignore-all-space $TMP/example_data.err2 $EXPECTED_ERR | wc -l`
if test ! $diffc = 0
then
echoerr "error: (2), diff $TMP/example_data.err2 $EXPECTED_ERR"
popd > /dev/null
exit 2
fi

Expand Down Expand Up @@ -260,7 +248,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: (3), Expected Result file $EXPECTED_SCO does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.scores.2 $EXPECTED_SCO"
Expand All @@ -272,7 +259,6 @@ runit() {
if test ! $diffc = 0
then
echoerr "error: (3) diff $TMP/example_data.scores.2 $EXPECTED_SCO"
popd > /dev/null
exit 3
fi

Expand Down Expand Up @@ -304,7 +290,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.xref.scores $EXPECTED_SCO"
Expand All @@ -315,7 +300,6 @@ runit() {
diff --ignore-all-space $TMP/example_data.xref.scores $EXPECTED_SCO > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum), diff $TMP/example_data.xref.scores $EXPECTED_SCO"
popd > /dev/null
exit $testnum
fi

Expand All @@ -334,7 +318,6 @@ runit() {
diff --ignore-all-space $TMP/example_data.xref.json_scores $EXPECTED_SCO > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum), diff $TMP/example_data.xref.json_scores $EXPECTED_SCO"
popd > /dev/null
exit $testnum
fi
echo "passed"
Expand Down Expand Up @@ -370,7 +353,6 @@ runit() {
if test $CREATE_EXP_FILE = 0
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/example_data.scores.2.T-201 $EXPECTED_SCO"
Expand All @@ -381,7 +363,6 @@ runit() {
diff --ignore-all-space $TMP/example_data.scores.2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) diff $TMP/example_data.scores.2.T-201 $EXPECTED_SCO"
popd > /dev/null
exit $testnum
fi
echo "passed"
Expand All @@ -398,7 +379,6 @@ runit
if test "$1" = "_go"
then
echo "passed all example data tests (for go implementation)"
popd > /dev/null
exit 0
fi
runit "-xlen"
Expand Down Expand Up @@ -428,7 +408,6 @@ then
if test $CREATE_EXP_FILE = 0
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_TESTLEN does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/testlen.out $EXPECTED_TESTLEN"
Expand All @@ -439,7 +418,6 @@ fi
diff --ignore-all-space $TMP/testlen.out $EXPECTED_TESTLEN > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) diff $TMP/testlen.out $EXPECTED_TESTLEN"
popd > /dev/null
exit $testnum
fi
echo "passed"
Expand Down Expand Up @@ -467,7 +445,6 @@ for file in small small2 ; do
if test $CREATE_EXP_FILE = 0
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_TLSH does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/$file.tlsh $EXPECTED_TLSH"
Expand All @@ -478,7 +455,6 @@ for file in small small2 ; do
diff --ignore-all-space $TMP/$file.tlsh $EXPECTED_TLSH
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) $TMP/$file.tlsh $EXPECTED_TLSH"
popd > /dev/null
exit $testnum
fi
done
Expand Down Expand Up @@ -511,14 +487,12 @@ then
if test ! -f $EXPECTED_SCO
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist"
popd > /dev/null
exit 1
fi

diff --ignore-all-space $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) diff $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO"
popd > /dev/null
exit $testnum
fi

Expand All @@ -533,7 +507,6 @@ then
diff --ignore-all-space $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) diff $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO"
popd > /dev/null
exit $testnum
fi

Expand Down Expand Up @@ -563,14 +536,12 @@ then
if test ! -f $EXPECTED_RES
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_RES does not exist"
popd > /dev/null
exit 1
fi

diff --ignore-all-space $TMP/example_data.Week3.split.tlsh $EXPECTED_RES > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) diff $TMP/example_data.Week3.split.tlsh $EXPECTED_RES"
popd > /dev/null
exit $testnum
fi

Expand Down Expand Up @@ -598,7 +569,6 @@ then
if test $CREATE_EXP_FILE = 0
then
echoerr "error: ($testnum), Expected Result file $EXPECTED_STEST does not exist"
popd > /dev/null
exit 1
else
echo "cp $TMP/simple_unittest.out $EXPECTED_STEST"
Expand All @@ -609,14 +579,11 @@ fi
diff --ignore-all-space $TMP/simple_unittest.out $EXPECTED_STEST > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: ($testnum) diff $TMP/simple_unittest.out $EXPECTED_STEST"
popd > /dev/null
exit -1
exit 255
fi

echo "passed all example data tests"

popd > /dev/null

echo
echo "If you have made changes to the Tlsh python module, build and install it, and run python_test.sh"
echo
8 changes: 2 additions & 6 deletions Testing/test_parts.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
#!/bin/bash
#!/bin/sh

export LC_ALL='C'

echoerr() { echo "$@" 1>&2; }

BASEDIR=$(dirname $0)
pushd $BASEDIR > /dev/null
cd $BASEDIR > /dev/null

if test ! -f ../bin/tlsh
then
echoerr "error: (127), you must compile tlsh"
popd > /dev/null
exit 127
fi

if test ! -f ../bin/tlsh_parts
then
echoerr "error: (127), you must compile ../bin/tlsh_parts"
popd > /dev/null
exit 127
fi

Expand All @@ -34,14 +32,12 @@ EXPECTED_PARTS=exp/out.parts_EXP
if test ! -f $EXPECTED_PARTS
then
echoerr "error: Expected parts file $EXPECTED_PARTS does not exist"
popd > /dev/null
exit 1
fi

diff --ignore-all-space out.parts $EXPECTED_PARTS > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echoerr "error: diff out.parts $EXPECTED_PARTS"
popd > /dev/null
exit 1
fi
echo "passed"
Loading