<commit_before>#!/bin/bash
#set -x
#set -v

OS=`uname -s`
LDFLAGS='-shared'
if [ "$OS" = "Darwin" ]; then
  LDFLAGS='-shared -undefined dynamic_lookup'
fi
#Remove .so
find . -name "*.so" -exec rm {} +

#For plugin test, compile Percolator plugin
rm plugins/mock/percolator/libctrpercolator.so
rm mods/percolator/libctrpercolator.so
rm plugins/mockpercolator/percolator.o
cd plugins/mock/percolator;
cc -c percolator.c -Wall -Werror -fPIC -o percolator.o
cc ${LDFLAGS} -o libctrpercolator.so percolator.o
cd ..
cd ..
cd ..
cp plugins/mock/percolator/libctrpercolator.so mods/percolator/libctrpercolator.so


#rm plugins/percolator/libctrpercolator.so
#cd plugins/percolator;
#cc -DlangNL -c percolator.c -Wall -Werror -fPIC -o koffiezetter.o
#cc ${LDFLAGS} -o libctrkoffiezetter.so koffiezetter.o
#cd ..
#cd ..
#cp plugins/percolator/libctrkoffiezetter.so mods/koffiezetter/libctrkoffiezetter.so


#request test
cd plugins/request/ccgi-1.2;
cc -c ccgi.c -Wall	-Werror -fPIC -o ccgi.o
cc -c prefork.c -Wall -Werror -fPIC -o prefork.o
cd ..

cc -c request.c -Wall -Werror -DlangEN -fPIC -o request.o
cc ${LDFLAGS} -o libctrrequest.so request.o ccgi-1.2/ccgi.o ccgi-1.2/prefork.o

cc -c request.c -Wall -Werror -DlangNL -fPIC -o verzoek.o
cc ${LDFLAGS} -o libctrverzoek.so verzoek.o ccgi-1.2/ccgi.o ccgi-1.2/prefork.o

cd ..
cd ..

cp plugins/request/libctrrequest.so mods/request/libctrrequest.so
cp plugins/request/libctrverzoek.so mods/verzoek/libctrverzoek.so


#json test
cd plugins/jsmn/jsmn;
gcc -c jsmn.c -Wall	-Werror -fpic -DJSMN_STRICT -DJSMN_PARENT_LINKS -o jsmn.o
cd ..
gcc -c jsmn.c -Wall	-DlangEN -Werror -fpic -DJSMN_STRICT -DJSMN_PARENT_LINKS -o jsmn.o ; gcc -shared -o libctrjsmn.so jsmn.o jsmn/jsmn.o
gcc -c jsmn.c -Wall	-DlangNL -Werror -fpic -DJSMN_STRICT -DJSMN_PARENT_LINKS -o jsmnnl.o ; gcc -shared -o libctrjsmnnl.so jsmnnl.o jsmn/jsmn.o
cd ..
cd ..
cp plugins/jsmn/libctrjsmn.so mods/json/libctrjson.so
cp plugins/jsmn/libctrjsmnnl.so mods/jsonnl/libctrjsonnl.so

#curl test
rm plugins/curl/src/libctrcurl.so
rm plugins/curl/src/curl.o
rm mods/curl/libctrcurl.so
#cd plugins/curl/src;
#gcc -DCTRPLUGIN_CURL_CURLOPT_URL -c curl.c -Wall	-Werror -fpic -o curl.o
#gcc -shared -o libctrcurl.so curl.o -lcurl
#cd ..
#cd ..
#cd ..
#cp plugins/curl/src/libctrcurl.so mods/curl/libctrcurl.so

#pg test
rm plugins/pg/libctrpg.so
rm plugins/pg/pg.o
rm mods/pg/libctrpg.so
#cd plugins/pg;
#gcc -c pg.c -Wall -I/usr/include/postgresql/ -lpq -Werror -fpic -o pg.o
#gcc -shared -o libctrpg.so pg.o -I/usr/include/postgresql/ -lpq
#cd ..
#cd ..
#cp plugins/pg/libctrpg.so mods/pg/libctrpg.so

#sodium
rm plugins/crypt/libctrpassword.so
rm plugins/crypt/crypt.o
rm mods/password/libctrpassword.so
#cd plugins/crypt;
#gcc -c crypt.c -Wall -I/usr/local/include/  -Werror -fpic -o crypt.o
#gcc -shared -o libctrpassword.so crypt.o -L/usr/local/lib/ -lsodium
#cd ..
#cd ..
#cp plugins/crypt/libctrpassword.so mods/password/libctrpassword.so

./mk.sh
j=1
for i in $(find tests -name 'test*.ctr'); do
	touch /tmp/a
	touch /tmp/b
	touch /tmp/c
	touch /tmp/d
	touch /tmp/transl.ctr
	fitem=$i
	echo "[suite: $fitem]";
	fexpect="${i%%.ctr}.exp"
	fexpectnl="${i%%.ctr}nl.exp"
	#test for every GC mode (0/1/4/8/9/12) mode x every language (EN/NL)
	rm tests/runner1.ctr ; echo "Program tidiness: 0." > tests/runner1.ctr ; cat ${fitem} >> tests/runner1.ctr
	rm tests/runner2.ctr ; echo "Program tidiness: 1." > tests/runner2.ctr ; cat ${fitem} >> tests/runner2.ctr
	rm tests/runner3.ctr ; echo "Program tidiness: 4." > tests/runner3.ctr ; cat ${fitem} >> tests/runner3.ctr
	rm tests/runner4.ctr ; echo "Program tidiness: 8." > tests/runner4.ctr ; cat ${fitem} >> tests/runner4.ctr
	rm tests/runner5.ctr ; echo "Program tidiness: 9." > tests/runner5.ctr ; cat ${fitem} >> tests/runner5.ctr
	rm tests/runner6.ctr ; echo "Program tidiness: 12." > tests/runner6.ctr ; cat ${fitem} >> tests/runner6.ctr
	directive=`head -n1 $fitem`
	echo "[translating...]"
	if [ "$directive" != "'SINGLE_LANGUAGE'." ]; then
		rm tests/runner7.ctr ; ./ctr -t ennl.dict tests/runner1.ctr 1> tests/runner7.ctr 2> tests/terrors7.log
		rm tests/runner8.ctr ; ./ctr -t ennl.dict tests/runner2.ctr 1> tests/runner8.ctr 2> tests/terrors8.log
		rm tests/runner9.ctr ; ./ctr -t ennl.dict tests/runner3.ctr 1> tests/runner9.ctr 2> tests/terrors9.log
		rm tests/runner10.ctr ; ./ctr -t ennl.dict tests/runner4.ctr 1> tests/runner10.ctr 2> tests/terrors10.log
		rm tests/runner11.ctr ; ./ctr -t ennl.dict tests/runner5.ctr 1> tests/runner11.ctr 2> tests/terrors11.log
		rm tests/runner12.ctr ; ./ctr -t ennl.dict tests/runner6.ctr 1> tests/runner12.ctr 2> tests/terrors12.log
	fi
	echo "[running...]";
	echo "test" | ./ctr ${fitem} 1>/tmp/a0 2>/tmp/b0
	echo "test" | ./ctr tests/runner1.ctr 1>/tmp/a1 2>/tmp/b1
	echo "test" | ./ctr tests/runner2.ctr 1>/tmp/a2 2>/tmp/b2
	echo "test" | ./ctr tests/runner3.ctr 1>/tmp/a3 2>/tmp/b3
	echo "test" | ./ctr tests/runner4.ctr 1>/tmp/a4 2>/tmp/b4
	echo "test" | ./ctr tests/runner5.ctr 1>/tmp/a5 2>/tmp/b5
	echo "test" | ./ctr tests/runner6.ctr 1>/tmp/a6 2>/tmp/b6
	if [ "$directive" != "'SINGLE_LANGUAGE'." ]; then
		echo "test" | ./ctrnl tests/runner7.ctr 1>/tmp/a7 2>/tmp/b7
		echo "test" | ./ctrnl tests/runner8.ctr 1>/tmp/a8 2>/tmp/b8
		echo "test" | ./ctrnl tests/runner9.ctr 1>/tmp/a9 2>/tmp/b9
		echo "test" | ./ctrnl tests/runner10.ctr 1>/tmp/a10 2>/tmp/b10
		echo "test" | ./ctrnl tests/runner11.ctr 1>/tmp/a11 2>/tmp/b11
		echo "test" | ./ctrnl tests/runner12.ctr 1>/tmp/a12 2>/tmp/b12
	fi
	result[0]=`cat /tmp/a0 /tmp/b0`
	result[1]=`cat /tmp/a1 /tmp/b1`
	result[2]=`cat /tmp/a2 /tmp/b2`
	result[3]=`cat /tmp/a3 /tmp/b3`
	result[4]=`cat /tmp/a4 /tmp/b4`
	result[5]=`cat /tmp/a5 /tmp/b5`
	result[6]=`cat /tmp/a6 /tmp/b6`
	result[7]=`cat /tmp/a7 /tmp/b7`
	result[8]=`cat /tmp/a8 /tmp/b8`
	result[9]=`cat /tmp/a9 /tmp/b9`
	result[10]=`cat /tmp/a10 /tmp/b10`
	result[11]=`cat /tmp/a11 /tmp/b11`
	result[12]=`cat /tmp/a12 /tmp/b12`
	expected=`cat $fexpect`
	expectednl=''
	if [ -f $fexpectnl ]; then
		expectednl=`cat $fexpectnl`
	fi
	if [ "${result[0]}" = "$expected" ]; then
		echo -n "[✓$j*]"
		j=$((j+1))
	else
		echo "FAIL."
		echo "EXPECTED:"
		echo $expected
		echo ""
		echo "BUT GOT:"
		echo $result[0]
		exit 1
	fi
    if [ "$directive" != "'SINGLE_LANGUAGE'." ]; then
		for q in {1..12}
		do<commit_msg>Fix issue in unit test causing segmentation faults not to be reported,<commit_after>#!/bin/bash
#set -x
#set -v

OS=`uname -s`
LDFLAGS='-shared'
if [ "$OS" = "Darwin" ]; then
  LDFLAGS='-shared -undefined dynamic_lookup'
fi
#Remove .so
find . -name "*.so" -exec rm {} +

#For plugin test, compile Percolator plugin
rm plugins/mock/percolator/libctrpercolator.so
rm mods/percolator/libctrpercolator.so
rm plugins/mockpercolator/percolator.o
cd plugins/mock/percolator;
cc -c percolator.c -Wall -Werror -fPIC -o percolator.o
cc ${LDFLAGS} -o libctrpercolator.so percolator.o
cd ..
cd ..
cd ..
cp plugins/mock/percolator/libctrpercolator.so mods/percolator/libctrpercolator.so


#rm plugins/percolator/libctrpercolator.so
#cd plugins/percolator;
#cc -DlangNL -c percolator.c -Wall -Werror -fPIC -o koffiezetter.o
#cc ${LDFLAGS} -o libctrkoffiezetter.so koffiezetter.o
#cd ..
#cd ..
#cp plugins/percolator/libctrkoffiezetter.so mods/koffiezetter/libctrkoffiezetter.so


#request test
cd plugins/request/ccgi-1.2;
cc -c ccgi.c -Wall	-Werror -fPIC -o ccgi.o
cc -c prefork.c -Wall -Werror -fPIC -o prefork.o
cd ..

cc -c request.c -Wall -Werror -DlangEN -fPIC -o request.o
cc ${LDFLAGS} -o libctrrequest.so request.o ccgi-1.2/ccgi.o ccgi-1.2/prefork.o

cc -c request.c -Wall -Werror -DlangNL -fPIC -o verzoek.o
cc ${LDFLAGS} -o libctrverzoek.so verzoek.o ccgi-1.2/ccgi.o ccgi-1.2/prefork.o

cd ..
cd ..

cp plugins/request/libctrrequest.so mods/request/libctrrequest.so
cp plugins/request/libctrverzoek.so mods/verzoek/libctrverzoek.so


#json test
cd plugins/jsmn/jsmn;
gcc -c jsmn.c -Wall	-Werror -fpic -DJSMN_STRICT -DJSMN_PARENT_LINKS -o jsmn.o
cd ..
gcc -c jsmn.c -Wall	-DlangEN -Werror -fpic -DJSMN_STRICT -DJSMN_PARENT_LINKS -o jsmn.o ; gcc -shared -o libctrjsmn.so jsmn.o jsmn/jsmn.o
gcc -c jsmn.c -Wall	-DlangNL -Werror -fpic -DJSMN_STRICT -DJSMN_PARENT_LINKS -o jsmnnl.o ; gcc -shared -o libctrjsmnnl.so jsmnnl.o jsmn/jsmn.o
cd ..
cd ..
cp plugins/jsmn/libctrjsmn.so mods/json/libctrjson.so
cp plugins/jsmn/libctrjsmnnl.so mods/jsonnl/libctrjsonnl.so

#curl test
rm plugins/curl/src/libctrcurl.so
rm plugins/curl/src/curl.o
rm mods/curl/libctrcurl.so
#cd plugins/curl/src;
#gcc -DCTRPLUGIN_CURL_CURLOPT_URL -c curl.c -Wall	-Werror -fpic -o curl.o
#gcc -shared -o libctrcurl.so curl.o -lcurl
#cd ..
#cd ..
#cd ..
#cp plugins/curl/src/libctrcurl.so mods/curl/libctrcurl.so

#pg test
rm plugins/pg/libctrpg.so
rm plugins/pg/pg.o
rm mods/pg/libctrpg.so
#cd plugins/pg;
#gcc -c pg.c -Wall -I/usr/include/postgresql/ -lpq -Werror -fpic -o pg.o
#gcc -shared -o libctrpg.so pg.o -I/usr/include/postgresql/ -lpq
#cd ..
#cd ..
#cp plugins/pg/libctrpg.so mods/pg/libctrpg.so

#sodium
rm plugins/crypt/libctrpassword.so
rm plugins/crypt/crypt.o
rm mods/password/libctrpassword.so
#cd plugins/crypt;
#gcc -c crypt.c -Wall -I/usr/local/include/  -Werror -fpic -o crypt.o
#gcc -shared -o libctrpassword.so crypt.o -L/usr/local/lib/ -lsodium
#cd ..
#cd ..
#cp plugins/crypt/libctrpassword.so mods/password/libctrpassword.so

./mk.sh
j=1
for i in $(find tests -name 'test*.ctr'); do
	touch /tmp/a
	touch /tmp/b
	touch /tmp/c
	touch /tmp/d
	touch /tmp/transl.ctr
	fitem=$i
	echo "[suite: $fitem]";
	fexpect="${i%%.ctr}.exp"
	fexpectnl="${i%%.ctr}nl.exp"
	#test for every GC mode (0/1/4/8/9/12) mode x every language (EN/NL)
	rm tests/runner1.ctr ; echo "Program tidiness: 0." > tests/runner1.ctr ; cat ${fitem} >> tests/runner1.ctr
	rm tests/runner2.ctr ; echo "Program tidiness: 1." > tests/runner2.ctr ; cat ${fitem} >> tests/runner2.ctr
	rm tests/runner3.ctr ; echo "Program tidiness: 4." > tests/runner3.ctr ; cat ${fitem} >> tests/runner3.ctr
	rm tests/runner4.ctr ; echo "Program tidiness: 8." > tests/runner4.ctr ; cat ${fitem} >> tests/runner4.ctr
	rm tests/runner5.ctr ; echo "Program tidiness: 9." > tests/runner5.ctr ; cat ${fitem} >> tests/runner5.ctr
	rm tests/runner6.ctr ; echo "Program tidiness: 12." > tests/runner6.ctr ; cat ${fitem} >> tests/runner6.ctr
	directive=`head -n1 $fitem`
	echo "[translating...]"
	if [ "$directive" != "'SINGLE_LANGUAGE'." ]; then
		rm tests/runner7.ctr ; ./ctr -t ennl.dict tests/runner1.ctr 1> tests/runner7.ctr 2> tests/terrors7.log
		rm tests/runner8.ctr ; ./ctr -t ennl.dict tests/runner2.ctr 1> tests/runner8.ctr 2> tests/terrors8.log
		rm tests/runner9.ctr ; ./ctr -t ennl.dict tests/runner3.ctr 1> tests/runner9.ctr 2> tests/terrors9.log
		rm tests/runner10.ctr ; ./ctr -t ennl.dict tests/runner4.ctr 1> tests/runner10.ctr 2> tests/terrors10.log
		rm tests/runner11.ctr ; ./ctr -t ennl.dict tests/runner5.ctr 1> tests/runner11.ctr 2> tests/terrors11.log
		rm tests/runner12.ctr ; ./ctr -t ennl.dict tests/runner6.ctr 1> tests/runner12.ctr 2> tests/terrors12.log
	fi
	echo "[running...]";
	echo "test" | ./ctr ${fitem} 1>/tmp/a0 2>/tmp/b0
	echo "test" | ./ctr tests/runner1.ctr 1>/tmp/a1 2>/tmp/b1
	echo "test" | ./ctr tests/runner2.ctr 1>/tmp/a2 2>/tmp/b2
	echo "test" | ./ctr tests/runner3.ctr 1>/tmp/a3 2>/tmp/b3
	echo "test" | ./ctr tests/runner4.ctr 1>/tmp/a4 2>/tmp/b4
	echo "test" | ./ctr tests/runner5.ctr 1>/tmp/a5 2>/tmp/b5
	echo "test" | ./ctr tests/runner6.ctr 1>/tmp/a6 2>/tmp/b6
	if [ "$directive" != "'SINGLE_LANGUAGE'." ]; then
		echo "test" | ./ctrnl tests/runner7.ctr 1>/tmp/a7 2>/tmp/b7
		echo "test" | ./ctrnl tests/runner8.ctr 1>/tmp/a8 2>/tmp/b8
		echo "test" | ./ctrnl tests/runner9.ctr 1>/tmp/a9 2>/tmp/b9
		echo "test" | ./ctrnl tests/runner10.ctr 1>/tmp/a10 2>/tmp/b10
		echo "test" | ./ctrnl tests/runner11.ctr 1>/tmp/a11 2>/tmp/b11
		echo "test" | ./ctrnl tests/runner12.ctr 1>/tmp/a12 2>/tmp/b12
	fi
	result[0]=`cat /tmp/a0 /tmp/b0`
	result[1]=`cat /tmp/a1 /tmp/b1`
	result[2]=`cat /tmp/a2 /tmp/b2`
	result[3]=`cat /tmp/a3 /tmp/b3`
	result[4]=`cat /tmp/a4 /tmp/b4`
	result[5]=`cat /tmp/a5 /tmp/b5`
	result[6]=`cat /tmp/a6 /tmp/b6`
	result[7]=`cat /tmp/a7 /tmp/b7`
	result[8]=`cat /tmp/a8 /tmp/b8`
	result[9]=`cat /tmp/a9 /tmp/b9`
	result[10]=`cat /tmp/a10 /tmp/b10`
	result[11]=`cat /tmp/a11 /tmp/b11`
	result[12]=`cat /tmp/a12 /tmp/b12`
	expected=`cat $fexpect`
	expectednl=$expected
	if [ -f $fexpectnl ]; then
		expectednl=`cat $fexpectnl`
	fi
	if [ "${result[0]}" = "$expected" ]; then
		echo -n "[✓$j*]"
		j=$((j+1))
	else
		echo "FAIL."
		echo "EXPECTED:"
		echo $expected
		echo ""
		echo "BUT GOT:"
		echo $result[0]
		exit 1
	fi
    if [ "$directive" != "'SINGLE_LANGUAGE'." ]; then
		for q in {1..12}
		do
{'fraction_non_alphanumeric': 0.1716265155093686, 'fraction_numerical': 0.034167847583057784, 'mean_word_length': 3.306101694915254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5057831', 'n_tokens_mistral': 5819, 'n_tokens_neox': 5720, 'n_words': 1258}