aba7ab1
#!/bin/bash
aba7ab1
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
aba7ab1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aba7ab1
#
aba7ab1
#   runtest.sh of /CoreOS/libselinux/Sanity/realpath_not_final-function
aba7ab1
#   Description: Test realpath_not_final function
aba7ab1
#   Author: Jan Zarsky <jzarsky@redhat.com>
aba7ab1
#
aba7ab1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aba7ab1
#
aba7ab1
#   Copyright (c) 2016 Red Hat, Inc.
aba7ab1
#
aba7ab1
#   This program is free software: you can redistribute it and/or
aba7ab1
#   modify it under the terms of the GNU General Public License as
aba7ab1
#   published by the Free Software Foundation, either version 2 of
aba7ab1
#   the License, or (at your option) any later version.
aba7ab1
#
aba7ab1
#   This program is distributed in the hope that it will be
aba7ab1
#   useful, but WITHOUT ANY WARRANTY; without even the implied
aba7ab1
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
aba7ab1
#   PURPOSE.  See the GNU General Public License for more details.
aba7ab1
#
aba7ab1
#   You should have received a copy of the GNU General Public License
aba7ab1
#   along with this program. If not, see http://www.gnu.org/licenses/.
aba7ab1
#
aba7ab1
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aba7ab1
aba7ab1
# Include Beaker environment
aba7ab1
. /usr/share/beakerlib/beakerlib.sh || exit 1
aba7ab1
aba7ab1
PACKAGE="libselinux"
aba7ab1
aba7ab1
rlJournalStart
aba7ab1
    rlPhaseStartSetup
aba7ab1
        rlAssertRpm ${PACKAGE}
aba7ab1
        rlAssertRpm ${PACKAGE}-devel
aba7ab1
        rlAssertRpm "glibc"
aba7ab1
        rlAssertRpm "gcc"
aba7ab1
aba7ab1
        rlRun -l "gcc test.c -o test -lselinux -Wall -Wextra -std=c99"
aba7ab1
    rlPhaseEnd
aba7ab1
aba7ab1
    rlPhaseStartTest
aba7ab1
        # syntax: ./test name [resolved_path]
aba7ab1
        rlRun "./test NULL" 139
aba7ab1
        rlRun "./test /somedir/somefile NULL" 255
aba7ab1
        rlRun "./test NULL NULL" 139
aba7ab1
aba7ab1
        rlRun "./test /tmp | tee output"
aba7ab1
        rlRun "grep 'realpath_not_final: /tmp' output"
aba7ab1
aba7ab1
        rlRun "./test //tmp | tee output"
aba7ab1
        rlRun "grep -E 'realpath_not_final: /tmp|realpath_not_final: //tmp' output"
aba7ab1
aba7ab1
        rlRun "./test ///tmp | tee output"
aba7ab1
        rlRun "grep -E 'realpath_not_final: /tmp|realpath_not_final: //tmp' output"
aba7ab1
        
aba7ab1
        rlRun "./test ////tmp | tee output"
aba7ab1
        rlRun "grep -E 'realpath_not_final: /tmp|realpath_not_final: //tmp' output"
aba7ab1
    rlPhaseEnd
aba7ab1
aba7ab1
    rlPhaseStartCleanup
aba7ab1
        rlRun "rm -f test output"
aba7ab1
    rlPhaseEnd
aba7ab1
rlJournalPrintText
aba7ab1
rlJournalEnd