#! @ATF_SH@ # Copyright 2012 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Google Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Path to a local cvsroot for testing purposes. MOCK_CVSROOT=":local:$(pwd)/cvsroot" # Paths to installed files. # # Can be overriden for test purposes only. : ${SYSBUILD_SHAREDIR="@SYSBUILD_SHAREDIR@"} # Creates a fake program that records its invocations for later processing. # # The fake program, when invoked, will append its arguments to a commands.log # file in the test case's work directory. # # \param binary The path to the program to create. # \param delegate If set to 'yes', execute the real program afterwards. create_mock_binary() { local binary="${1}"; shift local delegate=no [ ${#} -eq 0 ] || { delegate="${1}"; shift; } cat >"${binary}" <>"\${logfile}" echo "Directory: \$(pwd)" >>"\${logfile}" for arg in "\${@}"; do echo "Arg: \${arg}" >>"\${logfile}" done echo >>"\${logfile}" EOF if [ "${delegate}" = yes ]; then cat >>"${binary}" <file-in-src cvs -d "${repository}" import -m "Import." src VENDOR_TAG release_tag cd - rm -rf src mkdir xsrc cd xsrc echo "first revision" >file-in-xsrc cvs -d "${repository}" import -m "Import." xsrc VENDOR_TAG release_tag cd - rm -rf xsrc } atf_test_case build__custom_dirs build__custom_dirs_body() { create_mock_cvsroot "${MOCK_CVSROOT}" create_mock_binary cvs yes PATH="$(pwd):${PATH}" cat >test.conf <expout <expout <expout <expout <expout <experr <expout <expout <expout <test.conf <exp_order <test.conf <exp_order <test.conf <exp_order <expout <expout <my-file atf_check -o match:"BUILD_TARGETS = foo" sysbuild -c ./my-file config } atf_test_case config__path__extension config__path__extension_body() { mkdir .sysbuild mkdir system export SYSBUILD_ETCDIR="$(pwd)/system" echo "BUILD_TARGETS=bar" >my-file.conf atf_check -o match:"BUILD_TARGETS = bar" sysbuild -c my-file.conf config } atf_test_case config__name__system_directory config__name__system_directory_body() { mkdir .sysbuild mkdir system export SYSBUILD_ETCDIR="$(pwd)/system" echo "BUILD_TARGETS='some value'" >system/foo.conf atf_check -o match:"BUILD_TARGETS = some value" sysbuild -c foo config } atf_test_case config__name__user_directory config__name__user_directory_body() { mkdir .sysbuild mkdir system export SYSBUILD_ETCDIR="$(pwd)/system" echo "BUILD_TARGETS='some value'" >system/foo.conf echo "BUILD_TARGETS='other value'" >.sysbuild/foo.conf atf_check -o match:"BUILD_TARGETS = other value" sysbuild -c foo config } atf_test_case config__name__not_found config__name__not_found_body() { mkdir .sysbuild mkdir system export SYSBUILD_ETCDIR="$(pwd)/system" cat >experr <custom.conf <expout <experr <expout <expout <expout <root/mach/tools/bin/nbmake-mach <experr <experr <test.conf <test.conf <test.conf <file-in-src cvs commit -m "Second revision." cd - test -f checkout/src/file-in-src || atf_fail "src not present yet" if grep "second revision" checkout/src/file-in-src >/dev/null; then atf_fail "second revision already present" fi atf_check -o ignore -e not-match:"xsrc" sysbuild -c test.conf fetch grep "second revision" checkout/src/file-in-src >/dev/null \ || atf_fail "src not updated" test ! -d checkout/xsrc || atf_fail "xsrc checked out but not requested" } atf_test_case fetch__update__src_and_xsrc fetch__update__src_and_xsrc_body() { create_mock_cvsroot "${MOCK_CVSROOT}" cat >test.conf <file-in-src cvs commit -m "Second revision." cd - cp -rf checkout/xsrc xsrc-copy cd xsrc-copy echo "second revision" >file-in-xsrc cvs commit -m "Second revision." cd - test -f checkout/src/file-in-src || atf_fail "src not present yet" if grep "second revision" checkout/src/file-in-src >/dev/null; then atf_fail "second revision already present" fi test -f checkout/xsrc/file-in-xsrc || atf_fail "xsrc not present yet" if grep "second revision" checkout/xsrc/file-in-xsrc >/dev/null; then atf_fail "second revision already present" fi atf_check -o ignore -e ignore sysbuild -c test.conf fetch grep "second revision" checkout/src/file-in-src >/dev/null \ || atf_fail "src not updated" grep "second revision" checkout/xsrc/file-in-xsrc >/dev/null \ || atf_fail "xsrc not updated" } atf_test_case fetch__hooks__ok fetch__hooks__ok_body() { create_mock_cvsroot "${MOCK_CVSROOT}" cat >test.conf <exp_order <test.conf <exp_order <test.conf <exp_order <experr <experr <experr <experr <