]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/tests/core/test_post_scripts.py
7ca9b9d836eeafe1d7e50ef9a31970839d92d3a4
[coffee/buildroot.git] / support / testing / tests / core / test_post_scripts.py
1 import os
2 import csv
3
4 import infra.basetest
5
6 class TestPostScripts(infra.basetest.BRTest):
7     config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
8         """
9         BR2_INIT_NONE=y
10         BR2_SYSTEM_BIN_SH_NONE=y
11         # BR2_PACKAGE_BUSYBOX is not set
12         BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
13         BR2_ROOTFS_POST_IMAGE_SCRIPT="{}"
14         BR2_ROOTFS_POST_SCRIPT_ARGS="foobar baz"
15         """.format(infra.filepath("tests/core/post-build.sh"),
16                    infra.filepath("tests/core/post-image.sh"))
17
18     def check_post_log_file(self, path, what):
19         lines = {}
20         with open(path, 'rb') as csvfile:
21             r = csv.reader(csvfile, delimiter=',')
22             for row in r:
23                 lines[row[0]] = row[1]
24
25         self.assertEqual(lines["arg1"], os.path.join(self.builddir, what))
26         self.assertEqual(lines["arg2"], "foobar")
27         self.assertEqual(lines["arg3"], "baz")
28         self.assertEqual(lines["TARGET_DIR"], os.path.join(self.builddir, "target"))
29         self.assertEqual(lines["BUILD_DIR"], os.path.join(self.builddir, "build"))
30         self.assertEqual(lines["HOST_DIR"], os.path.join(self.builddir, "host"))
31         staging = os.readlink(os.path.join(self.builddir, "staging"))
32         self.assertEqual(lines["STAGING_DIR"], staging)
33         self.assertEqual(lines["BINARIES_DIR"], os.path.join(self.builddir, "images"))
34         self.assertEqual(lines["BR2_CONFIG"], os.path.join(self.builddir, ".config"))
35
36     def test_run(self):
37         f = os.path.join(self.builddir, "build", "post-build.log")
38         self.check_post_log_file(f, "target")
39         f = os.path.join(self.builddir, "build", "post-image.log")
40         self.check_post_log_file(f, "images")