Adds a Makefile with all, clean, and test targets.
This has only been added for demos that already contain Makefiles.
For problematic tests that require inputs, the test target does nothing.
(Note: Demos should be self contained and not require unknown external
inputs. This PR does not attempt to fix this.)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20546)
--- /dev/null
+MODULES=bio digest encode encrypt kdf keyexch mac pkey signature sslecho
+
+all:
+ @set -e; for i in $(MODULES); do \
+ ${MAKE} -C $$i all; \
+ done
+clean:
+ @set -e; for i in $(MODULES); do \
+ ${MAKE} -C $$i clean; \
+ done
+test:
+ @set -e; for i in $(MODULES); do \
+ ${MAKE} -C $$i test; \
+ done
all: client-arg client-conf saccept sconnect server-arg server-cmod server-conf
+test:
+
client-arg: client-arg.o
client-conf: client-conf.o
saccept: saccept.o
CFLAGS = $(OPENSSL_INCS_LOCATION)
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
-all: aesccm aesgcm aeskeywrap ariacbc
+TESTS=aesccm aesgcm aeskeywrap ariacbc
+
+all: $(TESTS)
aesccm: aesccm.o
aesgcm: aesgcm.o
clean:
$(RM) aesccm aesgcm aeskeywrap ariacbc *.o
+
+.PHONY: test
+test: all
+ @echo "\nCipher tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
LDFLAGS = -L../..
LDLIBS = -lcrypto
-all: EVP_MD_demo EVP_MD_stdin EVP_MD_xof BIO_f_md
+TESTS=EVP_MD_demo EVP_MD_stdin EVP_MD_xof BIO_f_md
+
+all: $(TESTS)
%.o: %.c
$(CC) $(CFLAGS) -c $<
EVP_MD_xof: EVP_MD_xof.o
BIO_f_md: BIO_f_md.o
-test: ;
+.PHONY: test
+# Since some of these tests use stdin we use the source file as stdin when running the exes
+test: all
+ @echo "\nDigest tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ cat $$tst.c | ./$$tst; \
+ done
clean:
- $(RM) *.o EVP_MD_demo EVP_MD_stdin EVP_MD_xof BIO_f_md
+ $(RM) *.o $(TESTS)
LDFLAGS = -L../..
LDLIBS = -lcrypto
-all: ec_encode rsa_encode
+TESTS=ec_encode rsa_encode
+
+all: $(TESTS)
%.o: %.c
$(CC) $(CFLAGS) -c $<
%_encode: %_encode.o
-test: ;
+test:
clean:
- $(RM) *.o rsa_encode ec_encode
+ $(RM) *.o $(TESTS)
LDFLAGS = -L../..
LDLIBS = -lcrypto
-all: rsa_encrypt
+TESTS=rsa_encrypt
+
+all: $(TESTS)
%.o: %.c
$(CC) $(CFLAGS) -c $<
rsa_encrypt: rsa_encrypt.o
-test: ;
-
clean:
- $(RM) *.o rsa_encrypt
+ $(RM) *.o $(TESTS)
+
+.PHONY: test
+test: all
+ @echo "\nEncrypt tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
LDFLAGS = -L../..
LDLIBS = -lcrypto
-all: hkdf pbkdf2 scrypt argon2
+TESTS=hkdf pbkdf2 scrypt argon2
+
+all: $(TESTS)
%.o: %.c
$(CC) $(CFLAGS) -c $<
hkdf: hkdf.o
pbkdf2: pbkdf2.o
scrypt: scrypt.o
-
-test: ;
+argon2: argon2.o
clean:
- $(RM) *.o hkdf pbkdf2 scrypt argon2
+ $(RM) *.o $(TESTS)
+
+.PHONY: test
+test: all
+ @echo "\nKDF tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
--- /dev/null
+#
+# To run the demos when linked with a shared library (default):
+#
+# LD_LIBRARY_PATH=../.. ./x25519
+
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
+
+TESTS=x25519
+
+all: $(TESTS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
+
+%x25519: %x25519.o
+
+.PHONY: test
+test: all
+ @echo "\nKeyExchange tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
+
+clean:
+ $(RM) *.o $(TESTS)
CFLAGS = $(OPENSSL_INCS_LOCATION) -Wall
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
-all: gmac hmac-sha512 cmac-aes256 poly1305
+TESTS=gmac hmac-sha512 cmac-aes256 poly1305
+
+all: $(TESTS)
gmac: gmac.o
hmac-sha512: hmac-sha512.o
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
clean:
- $(RM) gmac hmac-sha512 cmac-aes256 poly1305 *.o
+ $(RM) *.o $(TESTS)
+
+.PHONY: test
+test: all
+ @echo "\nMAC tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
LDFLAGS = -L../..
LDLIBS = -lcrypto
-all: EVP_PKEY_EC_keygen EVP_PKEY_RSA_keygen EVP_PKEY_DSA_keygen \
- EVP_PKEY_DSA_paramgen EVP_PKEY_DSA_paramvalidate EVP_PKEY_DSA_paramfromdata \
+TESTS=EVP_PKEY_EC_keygen EVP_PKEY_RSA_keygen EVP_PKEY_DSA_keygen \
+EVP_PKEY_DSA_paramgen EVP_PKEY_DSA_paramvalidate EVP_PKEY_DSA_paramfromdata
+
+all: $(TESTS)
%.o: %.c dsa.inc
$(CC) $(CFLAGS) -c $<
EVP_PKEY_DSA_paramfromdata: EVP_PKEY_DSA_paramfromdata.o
-test: ;
-
clean:
- $(RM) *.o EVP_PKEY_EC_keygen EVP_PKEY_RSA_keygen EVP_PKEY_DSA_keygen \
- EVP_PKEY_DSA_paramgen EVP_PKEY_DSA_paramfromdata EVP_PKEY_DSA_paramvalidate
+ $(RM) *.o $(TESTS)
+
+.PHONY: test
+test: all
+ @echo "\nPKEY tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
LDFLAGS = -L../..
LDLIBS = -lcrypto
-all: EVP_EC_Signature_demo EVP_DSA_Signature_demo EVP_ED_Signature_demo rsa_pss_direct rsa_pss_hash
+TESTS=EVP_EC_Signature_demo EVP_DSA_Signature_demo EVP_ED_Signature_demo rsa_pss_direct rsa_pss_hash
+
+all: $(TESTS)
%.o: %.c
$(CC) $(CFLAGS) -c $<
rsa_pss_direct: rsa_pss_direct.o
rsa_pss_hash: rsa_pss_hash.o
-test: ;
-
clean:
- $(RM) *.o EVP_EC_Signature_demo EVP_DSA_Signature_demo EVP_ED_Signature_demo rsa_pss_direct rsa_pss_hash
+ $(RM) *.o $(TESTS)
+
+.PHONY: test
+test: all
+ @echo "\nSignature tests:"
+ @set -e; for tst in $(TESTS); do \
+ echo "\n"$$tst; \
+ LD_LIBRARY_PATH=../.. ./$$tst; \
+ done
$(CC) -O0 -g3 -W -Wall -I../../include -L../../ -o $(PROG) main.c -lssl -lcrypto
+test:
+
clean:
rm -rf $(PROG) *.o *.obj