aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-09-03 23:49:37 +0200
committerLoïc Hoguin <[email protected]>2015-09-03 23:49:37 +0200
commit5d0834bd9dd6507e08d19de9b0b507d528efa7ac (patch)
treed5ff1ca30691f46549000030fc5cfea82787f76a /test/Makefile
parent77e8b7c59053d0b3401c6e770f355b8fc9cda3d0 (diff)
downloaderlang.mk-5d0834bd9dd6507e08d19de9b0b507d528efa7ac.tar.gz
erlang.mk-5d0834bd9dd6507e08d19de9b0b507d528efa7ac.tar.bz2
erlang.mk-5d0834bd9dd6507e08d19de9b0b507d528efa7ac.zip
Add a test for building .asn1 files
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile134
1 files changed, 133 insertions, 1 deletions
diff --git a/test/Makefile b/test/Makefile
index d75d0b1..05357f9 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -22,6 +22,10 @@ APP_TO_CLEAN = $(subst -,_,$(patsubst clean-%,%,$@))
ERL = erl +A0 -noinput -boot start_clean
+# OTP master, for downloading files for testing.
+
+OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master
+
# t = Verbosity control for tests
# v = Verbosity control for erlang.mk
# i = Command to display (or suppress) info messages
@@ -67,10 +71,138 @@ build:
.PHONY: core clean-core
-core: core-upgrade
+core: core-app core-upgrade
clean-core: clean-core-upgrade
+# Core: Building applications.
+
+CORE_APP_CASES = asn1 hrl hrl-recursive mib xrl yrl
+CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
+CORE_APP_CLEAN_TARGETS = $(addprefix clean-,$(CORE_APP_TARGETS))
+
+.PHONY: core-app $(CORE_APP_TARGETS) $(CORE_APP_CLEAN_TARGETS)
+
+core-app: $(CORE_APP_TARGETS)
+
+core-app-asn1: build clean-core-app-asn1
+
+ $i "Bootstrap a new OTP library named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+ $i "Download .asn1 files from Erlang/OTP"
+ $t mkdir $(APP)/asn1/
+ $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
+ $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
+
+ $i "Generate .erl files dependent from headers generated by .asn1 files"
+ $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
+ $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/ebin/CAP.beam
+ $t test -f $(APP)/ebin/Def.beam
+ $t test -f $(APP)/ebin/use_cap.beam
+ $t test -f $(APP)/ebin/use_def.beam
+ $t test -f $(APP)/include/CAP.asn1db
+ $t test -f $(APP)/include/CAP.hrl
+ $t test -f $(APP)/include/Def.asn1db
+ $t test -f $(APP)/include/Def.hrl
+ $t test -f $(APP)/src/CAP.erl
+ $t test -f $(APP)/src/Def.erl
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
+ = application:get_key($(APP), modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Touch one .asn1 file; check that only required files are rebuilt"
+# The use_cap.erl gets touched because of its dependency to CAP.hrl.
+ $t printf "%s\n" \
+ $(APP)/$(APP).d \
+ $(APP)/ebin/$(APP).app \
+ $(APP)/ebin/CAP.beam \
+ $(APP)/ebin/use_cap.beam \
+ $(APP)/include/CAP.asn1db \
+ $(APP)/include/CAP.hrl \
+ $(APP)/src/CAP.erl \
+ $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
+ $t touch $(APP)/asn1/CAP.asn1
+ $t $(MAKE) -C $(APP) $v
+ $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
+ $t rm $(APP)/EXPECT
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
+ = application:get_key($(APP), modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Clean the application"
+ $t $(MAKE) -C $(APP) clean $v
+
+ $i "Check that source files still exist"
+ $t test -f $(APP)/Makefile
+ $t test -f $(APP)/erlang.mk
+ $t test -f $(APP)/asn1/CAP.asn1
+ $t test -f $(APP)/asn1/Def.asn1
+ $t test -d $(APP)/include/
+ $t test -f $(APP)/src/$(APP).app.src
+ $t test -f $(APP)/src/use_cap.erl
+ $t test -f $(APP)/src/use_def.erl
+
+ $i "Check that all build artifacts are removed, including intermediates"
+ $t test ! -e $(APP)/$(APP).d
+ $t test ! -e $(APP)/ebin/
+ $t test ! -e $(APP)/include/CAP.asn1db
+ $t test ! -e $(APP)/include/CAP.hrl
+ $t test ! -e $(APP)/include/Def.asn1db
+ $t test ! -e $(APP)/include/Def.hrl
+ $t test ! -e $(APP)/src/CAP.erl
+ $t test ! -e $(APP)/src/Def.erl
+
+ $i "Build the application again"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that all compiled files exist"
+ $t test -f $(APP)/$(APP).d
+ $t test -f $(APP)/ebin/$(APP).app
+ $t test -f $(APP)/ebin/CAP.beam
+ $t test -f $(APP)/ebin/Def.beam
+ $t test -f $(APP)/ebin/use_cap.beam
+ $t test -f $(APP)/ebin/use_def.beam
+ $t test -f $(APP)/include/CAP.asn1db
+ $t test -f $(APP)/include/CAP.hrl
+ $t test -f $(APP)/include/Def.asn1db
+ $t test -f $(APP)/include/Def.hrl
+ $t test -f $(APP)/src/CAP.erl
+ $t test -f $(APP)/src/Def.erl
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
+ = application:get_key($(APP), modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+clean-core-app: $(CORE_APP_CLEAN_TARGETS)
+
+$(CORE_APP_CLEAN_TARGETS):
+ $t rm -rf $(APP_TO_CLEAN)/
+
# Core: Erlang.mk upgrade.
CORE_UPGRADE_CASES = no-config custom-config renamed-config custom-build-dir