aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile101
1 files changed, 101 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
index e6cb7dc..82bb5ba 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -370,6 +370,107 @@ core-app-hrl-recursive: build clean-core-app-hrl-recursive
[{module, M} = code:load_file(M) || M <- Mods], \
halt()"
+core-app-mib: build clean-core-app-mib
+
+ $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 .mib files from Erlang/OTP"
+ $t mkdir $(APP)/mibs/
+ $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
+ $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
+
+ $i "Generate .erl files dependent from headers generated by .mib files"
+ $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
+ $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.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/use_v1.beam
+ $t test -f $(APP)/ebin/use_v2.beam
+ $t test -f $(APP)/include/EX1-MIB.hrl
+ $t test -f $(APP)/include/OTP-REG.hrl
+ $t test -f $(APP)/priv/mibs/EX1-MIB.bin
+ $t test -f $(APP)/priv/mibs/OTP-REG.bin
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = [use_v1, use_v2]} \
+ = application:get_key($(APP), modules), \
+ [{module, M} = code:load_file(M) || M <- Mods], \
+ halt()"
+
+ $i "Touch one .mib file; check that only required files are rebuilt"
+# The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
+ $t printf "%s\n" \
+ $(APP)/$(APP).d \
+ $(APP)/ebin/$(APP).app \
+ $(APP)/ebin/use_v1.beam \
+ $(APP)/include/EX1-MIB.hrl \
+ $(APP)/priv/mibs/EX1-MIB.bin \
+ $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
+ $t touch $(APP)/mibs/EX1-MIB.mib
+ $t $(MAKE) -C $(APP) $v
+ $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | 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 = [use_v1, use_v2]} \
+ = 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 -d $(APP)/include/
+ $t test -f $(APP)/mibs/EX1-MIB.mib
+ $t test -f $(APP)/mibs/OTP-REG.mib
+ $t test -f $(APP)/src/$(APP).app.src
+ $t test -f $(APP)/src/use_v1.erl
+ $t test -f $(APP)/src/use_v2.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/EX1-MIB.hrl
+ $t test ! -e $(APP)/include/OTP-REG.hrl
+ $t test ! -e $(APP)/priv/mibs/EX1-MIB.bin
+ $t test ! -e $(APP)/priv/mibs/OTP-REG.bin
+
+ $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/use_v1.beam
+ $t test -f $(APP)/ebin/use_v2.beam
+ $t test -f $(APP)/include/EX1-MIB.hrl
+ $t test -f $(APP)/include/OTP-REG.hrl
+ $t test -f $(APP)/priv/mibs/EX1-MIB.bin
+ $t test -f $(APP)/priv/mibs/OTP-REG.bin
+
+ $i "Check that the application was compiled correctly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:start($(APP)), \
+ {ok, Mods = [use_v1, use_v2]} \
+ = 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):