tests: run valgrind on a test, not on a shell

Rename scripts and use SH_LOG_COMPILER to call VALGRIND inside a script
rather than valgrinding the whole script (including bash and the rest of
utils).

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f850df7..82aa2c6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,8 +52,10 @@
 
 # For crlf.
 EXTRA_DIST += crlf.cer crl.der ocsp.der
-dist_check_SCRIPTS = crlf benchmark threadsafety decoding decoding-invalid-x509 \
-	decoding-invalid-pkcs7 coding parser.sh
+dist_check_SCRIPTS = crlf.sh benchmark.sh threadsafety.sh decoding.sh decoding-invalid-x509.sh \
+	decoding-invalid-pkcs7.sh coding.sh parser.sh
+
+TEST_EXTENSIONS = .sh
 
 MOSTLYCLEANFILES = Test_parser_ERROR.asn CVE-2018-1000654-1_asn1_tab.h CVE-2018-1000654-2_asn1_tab.h
 
@@ -64,11 +66,11 @@
 	spc_pe_image_data setof CVE-2018-1000654 reproducers object-id-encoding
 
 TESTS = Test_parser Test_tree Test_encoding Test_indefinite	\
-	Test_errors Test_simple Test_overflow crlf threadsafety \
+	Test_errors Test_simple Test_overflow crlf.sh threadsafety.sh \
 	Test_strings Test_choice Test_encdec copynode coding-decoding2 \
-	strict-der Test_choice_ocsp decoding decoding-invalid-x509 \
+	strict-der Test_choice_ocsp decoding.sh decoding-invalid-x509.sh \
 	ocsp-basic-response octet-string coding-long-oid object-id-decoding \
-	spc_pe_image_data decoding-invalid-pkcs7 coding setof \
+	spc_pe_image_data decoding-invalid-pkcs7.sh coding.sh setof \
 	CVE-2018-1000654 parser.sh reproducers object-id-encoding
 
 CVE-2018-1000654-1_asn1_tab.h: $(srcdir)/CVE-2018-1000654-1.asn
@@ -80,6 +82,7 @@
 CVE_2018_1000654_SOURCES = CVE-2018-1000654-1_asn1_tab.h CVE-2018-1000654-2_asn1_tab.h CVE-2018-1000654.c
 
 LOG_COMPILER = $(VALGRIND)
+SH_LOG_COMPILER= env VALGRIND="$(VALGRIND)" LIBTOOL="$(LIBTOOL)"
 
 TESTS_ENVIRONMENT = \
 	ASN1PARSER=$(srcdir)/Test_parser.asn \
diff --git a/tests/benchmark b/tests/benchmark.sh
similarity index 100%
rename from tests/benchmark
rename to tests/benchmark.sh
diff --git a/tests/coding b/tests/coding.sh
similarity index 100%
rename from tests/coding
rename to tests/coding.sh
diff --git a/tests/crlf b/tests/crlf.sh
similarity index 100%
rename from tests/crlf
rename to tests/crlf.sh
diff --git a/tests/decoding-invalid-pkcs7 b/tests/decoding-invalid-pkcs7.sh
similarity index 100%
rename from tests/decoding-invalid-pkcs7
rename to tests/decoding-invalid-pkcs7.sh
diff --git a/tests/decoding-invalid-x509 b/tests/decoding-invalid-x509.sh
similarity index 100%
rename from tests/decoding-invalid-x509
rename to tests/decoding-invalid-x509.sh
diff --git a/tests/decoding b/tests/decoding.sh
similarity index 100%
rename from tests/decoding
rename to tests/decoding.sh
diff --git a/tests/threadsafety b/tests/threadsafety.sh
similarity index 100%
rename from tests/threadsafety
rename to tests/threadsafety.sh