[U-Boot] [PATCH 1/3] buildman: Perform tests in /tmp

We may not always be able to write to the default output directory but we will always have a usable /tmp. Make the buildman tests use /tmp
Cc: Simon Glass sjg@chromium.org Signed-off-by: Tom Rini trini@konsulko.com --- tools/buildman/func_test.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 119d02cbb2b6..99cf46772639 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -421,7 +421,7 @@ class TestFunctional(unittest.TestCase): def testCurrentSource(self): """Very simple test to invoke buildman on the current source""" self.setupToolchains(); - self._RunControl() + self._RunControl('-o', '/tmp') lines = terminal.GetPrintTestLines() self.assertIn('Building current source for %d boards' % len(boards), lines[0].text) @@ -434,7 +434,7 @@ class TestFunctional(unittest.TestCase): def testBadToolchain(self): """Test that missing toolchains are detected""" self.setupToolchains(); - ret_code = self._RunControl('-b', TEST_BRANCH) + ret_code = self._RunControl('-b', TEST_BRANCH, '-o', '/tmp') lines = terminal.GetPrintTestLines()
# Buildman always builds the upstream commit as well @@ -458,13 +458,13 @@ class TestFunctional(unittest.TestCase):
def testBranch(self): """Test building a branch with all toolchains present""" - self._RunControl('-b', TEST_BRANCH) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp') self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._builder.fail, 0)
def testCount(self): """Test building a specific number of commitst""" - self._RunControl('-b', TEST_BRANCH, '-c2') + self._RunControl('-b', TEST_BRANCH, '-c2', '-o', '/tmp') self.assertEqual(self._builder.count, 2 * len(boards)) self.assertEqual(self._builder.fail, 0) # Each board has a mrproper, config, and then one make per commit @@ -472,34 +472,34 @@ class TestFunctional(unittest.TestCase):
def testIncremental(self): """Test building a branch twice - the second time should do nothing""" - self._RunControl('-b', TEST_BRANCH) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp')
# Each board has a mrproper, config, and then one make per commit self.assertEqual(self._make_calls, len(boards) * (self._commits + 2)) self._make_calls = 0 - self._RunControl('-b', TEST_BRANCH, clean_dir=False) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp', clean_dir=False) self.assertEqual(self._make_calls, 0) self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._builder.fail, 0)
def testForceBuild(self): """The -f flag should force a rebuild""" - self._RunControl('-b', TEST_BRANCH) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp') self._make_calls = 0 - self._RunControl('-b', TEST_BRANCH, '-f', clean_dir=False) + self._RunControl('-b', TEST_BRANCH, '-f', '-o', '/tmp', clean_dir=False) # Each board has a mrproper, config, and then one make per commit self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
def testForceReconfigure(self): """The -f flag should force a rebuild""" - self._RunControl('-b', TEST_BRANCH, '-C') + self._RunControl('-b', TEST_BRANCH, '-C', '-o', '/tmp') # Each commit has a mrproper, config and make self.assertEqual(self._make_calls, len(boards) * self._commits * 3)
def testErrors(self): """Test handling of build errors""" self._error['board2', 1] = 'fred\n' - self._RunControl('-b', TEST_BRANCH) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp') self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._builder.fail, 1)
@@ -507,13 +507,13 @@ class TestFunctional(unittest.TestCase): # not be rebuilt del self._error['board2', 1] self._make_calls = 0 - self._RunControl('-b', TEST_BRANCH, clean_dir=False) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp', clean_dir=False) self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._make_calls, 0) self.assertEqual(self._builder.fail, 1)
# Now use the -F flag to force rebuild of the bad commit - self._RunControl('-b', TEST_BRANCH, '-F', clean_dir=False) + self._RunControl('-b', TEST_BRANCH, '-o', '/tmp', '-F', clean_dir=False) self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._builder.fail, 0) self.assertEqual(self._make_calls, 3)

When running as another user we might not be able to use '..' for certain directories and this is the default for buildman. Specify an output directory instead.
Signed-off-by: Tom Rini trini@konsulko.com --- .gitlab-ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1c5b4fc766f..7ca71a0d6b37 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,9 +36,9 @@ stages: # use clang only do one configuration. - if [[ "${BUILDMAN}" != "" ]]; then ret=0; - tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?; + tools/buildman/buildman -o /tmp -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then - tools/buildman/buildman -sdeP ${BUILDMAN}; + tools/buildman/buildman -o /tmp -sdeP ${BUILDMAN}; exit $ret; fi; fi @@ -46,7 +46,7 @@ stages: # never prevent any test from running. That way, we can always pass # "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom # value. - - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD}; + - export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/${TEST_PY_BD}; export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:/usr/bin:/bin; export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci; if [[ "${TEST_PY_BD}" != "" ]]; then @@ -64,9 +64,9 @@ build all 32bit ARM plaforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -P -E arm -x aarch64 || ret=$?; + ./tools/buildman/buildman -o /tmp -P -E arm -x aarch64 || ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then - ./tools/buildman/buildman -sdeP; + ./tools/buildman/buildman -o /tmp -sdeP; exit $ret; fi;
@@ -78,9 +78,9 @@ build all 64bit ARM plaforms: - . /tmp/venv/bin/activate - pip install pyelftools - ret=0; - ./tools/buildman/buildman -P -E aarch64 || ret=$?; + ./tools/buildman/buildman -o /tmp -P -E aarch64 || ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then - ./tools/buildman/buildman -sdeP; + ./tools/buildman/buildman -o /tmp -sdeP; exit $ret; fi;
@@ -89,9 +89,9 @@ build all PowerPC plaforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -P -E powerpc || ret=$?; + ./tools/buildman/buildman -o /tmp -P -E powerpc || ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then - ./tools/buildman/buildman -sdeP; + ./tools/buildman/buildman -o /tmp -sdeP; exit $ret; fi;
@@ -100,9 +100,9 @@ build all other plaforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -P -E -x arm,powerpc || ret=$?; + ./tools/buildman/buildman -o /tmp -P -E -x arm,powerpc || ret=$?; if [[ $ret -ne 0 && $ret -ne 129 ]]; then - ./tools/buildman/buildman -sdeP; + ./tools/buildman/buildman -o /tmp -sdeP; exit $ret; fi;
@@ -162,10 +162,10 @@ Run binman, buildman, dtoc and patman testsuites: virtualenv /tmp/venv; . /tmp/venv/bin/activate; pip install pyelftools; - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/sandbox_spl; + export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/sandbox_spl; export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; - ./tools/buildman/buildman -P sandbox_spl; + ./tools/buildman/buildman -o /tmp -P sandbox_spl; ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test; ./tools/buildman/buildman -t; ./tools/dtoc/dtoc -t;

On 10/4/19 10:12 AM, Tom Rini wrote:
When running as another user we might not be able to use '..' for certain directories and this is the default for buildman. Specify an output directory instead.
What if multiple invocations run in parallel on the same machine? They'll use the same path and collide. What about using mkdtemp() or similar?

On Fri, Oct 04, 2019 at 10:34:05AM -0600, Stephen Warren wrote:
On 10/4/19 10:12 AM, Tom Rini wrote:
When running as another user we might not be able to use '..' for certain directories and this is the default for buildman. Specify an output directory instead.
What if multiple invocations run in parallel on the same machine? They'll use the same path and collide. What about using mkdtemp() or similar?
Within the confines of gitlab (as this runs in a container), that's not possible and this is no less safe than today.

On Fri, Oct 04, 2019 at 12:12:53PM -0400, Tom Rini wrote:
When running as another user we might not be able to use '..' for certain directories and this is the default for buildman. Specify an output directory instead.
Signed-off-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

In order to run all filesystem tests we need to have newer ext4 tools, move up to Ubuntu 18.04 'bionic' for our base. We need to change slightly how we invoke the provided grub-mkimage. This will also make future python3 work easier.
Signed-off-by: Tom Rini trini@konsulko.com --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ca71a0d6b37..27c65fcf956d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@
# Grab our configured image. The source for this is found at: # https://gitlab.denx.de/u-boot/gitlab-ci-runner -image: trini/u-boot-gitlab-ci-runner:xenial-20190720-02Aug2019 +image: trini/u-boot-gitlab-ci-runner:bionic-20190912.1-03Oct2019
# We run some tests in different order, to catch some failures quicker. stages: @@ -22,8 +22,9 @@ stages: - . /tmp/venv/bin/activate - pip install pytest==2.8.7 - pip install python-subunit - - grub-mkimage -o ~/grub_x86.efi -O i386-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd - - grub-mkimage -o ~/grub_x64.efi -O x86_64-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd + - pip install coverage + - grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd + - grub-mkimage --prefix="" -o ~/grub_x64.efi -O x86_64-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd - mkdir ~/grub2-arm - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/s... | rpm2cpio | cpio -di ) - mkdir ~/grub2-arm64

On Fri, Oct 04, 2019 at 12:12:54PM -0400, Tom Rini wrote:
In order to run all filesystem tests we need to have newer ext4 tools, move up to Ubuntu 18.04 'bionic' for our base. We need to change slightly how we invoke the provided grub-mkimage. This will also make future python3 work easier.
Signed-off-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

On 10/4/19 10:12 AM, Tom Rini wrote:
We may not always be able to write to the default output directory but we will always have a usable /tmp.
Is that a valid assumption? Surely $TMPDIR should be used if set in the environment, falling back to a hard-coded /tmp if that isn't set?

On Fri, Oct 04, 2019 at 10:32:42AM -0600, Stephen Warren wrote:
On 10/4/19 10:12 AM, Tom Rini wrote:
We may not always be able to write to the default output directory but we will always have a usable /tmp.
Is that a valid assumption? Surely $TMPDIR should be used if set in the environment, falling back to a hard-coded /tmp if that isn't set?
$TMPDIR is most portable but as far as Linux goes, there needs to be /tmp, yes?

On 10/4/19 11:26 AM, Tom Rini wrote:
On Fri, Oct 04, 2019 at 10:32:42AM -0600, Stephen Warren wrote:
On 10/4/19 10:12 AM, Tom Rini wrote:
We may not always be able to write to the default output directory but we will always have a usable /tmp.
Is that a valid assumption? Surely $TMPDIR should be used if set in the environment, falling back to a hard-coded /tmp if that isn't set?
$TMPDIR is most portable but as far as Linux goes, there needs to be /tmp, yes?
I don't think there absolutely has to be, no. Calling tempfile.mkdtemp() will "just work" and do the right thing in all cases.

On Fri, Oct 04, 2019 at 12:40:02PM -0600, Stephen Warren wrote:
On 10/4/19 11:26 AM, Tom Rini wrote:
On Fri, Oct 04, 2019 at 10:32:42AM -0600, Stephen Warren wrote:
On 10/4/19 10:12 AM, Tom Rini wrote:
We may not always be able to write to the default output directory but we will always have a usable /tmp.
Is that a valid assumption? Surely $TMPDIR should be used if set in the environment, falling back to a hard-coded /tmp if that isn't set?
$TMPDIR is most portable but as far as Linux goes, there needs to be /tmp, yes?
I don't think there absolutely has to be, no. Calling tempfile.mkdtemp() will "just work" and do the right thing in all cases.
OK, that wasn't too bad, waiting for any other feedback before v2'ing, thanks.

On Fri, 4 Oct 2019 at 09:13, Tom Rini trini@konsulko.com wrote:
We may not always be able to write to the default output directory but we will always have a usable /tmp. Make the buildman tests use /tmp
Cc: Simon Glass sjg@chromium.org Signed-off-by: Tom Rini trini@konsulko.com
tools/buildman/func_test.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
(this, or using $TMPDIR)
participants (3)
-
Simon Glass
-
Stephen Warren
-
Tom Rini