aboutsummaryrefslogtreecommitdiffstats
path: root/tests/recipes.mk
blob: f01c1add3b084014b02b77efc94ac6e5ebf3cd4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
#   Copyright (C) 2013 Intel Corporation; author Matt Fleming
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
#   Boston MA 02111-1307, USA; either version 2 of the License, or
#   (at your option) any later version; incorporated herein by reference.
#
# Canned recipes

#
# copy-files - copy a config to the mounted filesystem
# 
# Copies $(cfg) to the default Syslinux config location.
# Usually this wants pairing with a use of $(remove-config).
# 
# To use, your config filename must be the same as your target
#
define copy-files =
    for f in $($@_files); do \
	sudo cp $$f $(INSTALL_DIR) ;\
    done
    sync
endef

#
# install-config
#
define install-config =
    sudo sh -c 'echo INCLUDE $($@_cfg) >> $(CONFIG_FILE)'
    sync
endef

#
# remove-files - deletes files from the mounted filesystem
#
# Deletes $(mytest_files)
#
define remove-files =
    for f in $($@_files); do \
	sudo rm $(INSTALL_DIR)/$$f ;\
    done
endef

#
# delete-config - remove a test's config file from the master config
#
define delete-config =
    sudo sed -i -e '/INCLUDE $($@_cfg)/d' $(CONFIG_FILE)
endef

#
# run-test - begin executing the tests
#
define run-test =
    $(copy-files)
    $(install-config)

    sudo $(QEMU) $(QEMU_FLAGS) -serial file:$@.log

    $(delete-config)
    $(remove-files)

    sudo sort $@.log -o $@.log
    if [ `comm -1 -3 $@.log $($@_results) | wc -l` -ne 0 ]; then \
        printf "      [!] $@ failed\n" ;\
    else \
        printf "      [+] $@ passed\n" ;\
    fi
endef