| PORT=/dev/ttyS0 #TODO(apenwarr): don't hardcode this |
| PASSWORD=google |
| PORTSH=./portsh/portsh -p'$(PASSWORD)' |
| NMAP_SUBNETS=192.168.2.0/24 #TODO(apenwarr): auto-read the subnet from eth1? |
| |
| default: all |
| |
| all: map.stamp |
| |
| lint: |
| gpylint *.py configs/core.py |
| |
| test: |
| wvtest/wvtestrun $(MAKE) runtests |
| |
| test_with_output: |
| $(MAKE) runtests &> result.txt |
| wvtest_result_converter.py result.txt result.xml |
| |
| #TODO(apenwarr): use a smarter allocator. |
| # We could enable parallelism by depending on $(addsuffix ...) instead of |
| # looping through them one by one. But then we end up running multiple |
| # tests on the same device at once, which would cause conflicts. We need |
| # a smarter allocator first. |
| runtests: localtests install-wvtest |
| for d in $(addsuffix .run,$(wildcard [0-9]*.sh [0-9]*.py)); do \ |
| $(MAKE) $$d; \ |
| done |
| |
| localtests: |
| ./wvtest/wvtest.py *_test.py configs/*_test.py |
| |
| install-wvtest: map.stamp *.py *.sh wvtest/* |
| @echo 'Testing "install-wvtest" in Makefile:' |
| tar -cf - $^ | \ |
| $(PORTSH) $(PORT) \ |
| 'mkdir -p /tmp/tests && cd /tmp/tests && tar -xf -' |
| |
| %.sh.run: %.sh |
| echo "Testing $<" |
| $(PORTSH) $(PORT) \ |
| 'cd /tmp/tests && sh ./$<' </dev/null |
| |
| %.py.run: %.py |
| echo "Testing $<" |
| $(PORTSH) $(PORT) \ |
| 'cd /tmp/tests && python ./wvtest/wvtest.py $<' </dev/null |
| |
| # This rule regenerates the map *every* time. Run it when your node |
| # configuration has changed. |
| map: serialmap nmap |
| touch map.stamp |
| |
| # This rule just runs once; 'make map' or delete map.stamp to re-run. |
| # Depend on this rule to ensure we have a map, without regenerating it |
| # every time we run make. |
| map.stamp: |
| $(MAKE) map |
| |
| nmap: |
| rm -f configs/nmap.*.tmp |
| $(MAKE) $$(nmap -n -p22 -oG - $(NMAP_SUBNETS) | \ |
| grep ^Host: | \ |
| awk '{printf "configs/nmap.%s.tmp\n", $$2}') |
| cat configs/header configs/nmap.*.tmp >configs/auto_nmap.py.new |
| mv configs/auto_nmap.py.new configs/auto_nmap.py |
| |
| serialmap: |
| rm -f configs/tty.*.tmp |
| $(MAKE) $$(cd /dev && /bin/ls ttyS*[0-9] ttyUSB*[0-9] | \ |
| awk '{printf "configs/tty.%s.tmp\n", $$1}') |
| cat configs/header configs/tty.*.tmp >configs/auto_serial.py.new |
| mv configs/auto_serial.py.new configs/auto_serial.py |
| |
| |
| PROBE_CMD=\ |
| PATH=$$PATH:/bin:/usr/bin:/sbin:/usr/sbin; \ |
| hnvram -r 1ST_SERIAL_NUMBER -r SERIAL_NO -r MAC_ADDR -r PLATFORM_NAME; \ |
| [ -e /tmp/NFS ] && echo IS_NFSROOT=1; \ |
| ip addr show br0; \ |
| ip addr show eth0; \ |
| ip addr show eth1; \ |
| ip addr show eth2; \ |
| ip addr show eth4; \ |
| cat /proc/cpuinfo |
| |
| configs/nmap.%.tmp: |
| ssh -oNumberOfPasswordPrompts=0 \ |
| root@$* \ |
| 'echo NET_OK=1; $(PROBE_CMD)' 2>&1 | \ |
| ./parse-probe-data >$@.new |
| mv $@.new $@ |
| |
| configs/tty.%.tmp: |
| $(PORTSH) $* \ |
| 'echo SERIALPORT=$*; $(PROBE_CMD)' 2>&1 | \ |
| ./parse-probe-data >$@.new |
| mv $@.new $@ |
| |
| clean: |
| rm -f *~ .*~ */*~ */.*~ *.pyc */*.pyc *.stamp \ |
| configs/*.tmp configs/*.new configs/auto_*.py |