psss / rpms / libselinux

Forked from rpms/libselinux 5 years ago
Clone
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/selinux_sestatus-functions
aba7ab1
#   Description: Test sestatus.c functions
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
aba7ab1
        rlRun -l "gcc test.c -o test -lselinux -pedantic -Wall -Wextra -std=c99"
aba7ab1
    rlPhaseEnd
aba7ab1
aba7ab1
    rlPhaseStartTest
aba7ab1
        rlRun "./test > res.txt"
aba7ab1
        rlRun -l "cat res.txt"
aba7ab1
aba7ab1
        SELINUX_MNT=$(cat /proc/mounts | grep selinux | cut -d " " -f 2)
aba7ab1
aba7ab1
        rlRun "grep \"(before open) selinux_status_getenforce -1\" res.txt"
aba7ab1
        rlRun "grep \"(before open) selinux_status_policyload -1\" res.txt"
aba7ab1
        rlRun "grep \"(before open) selinux_status_deny_unknown -1\" res.txt"
aba7ab1
        rlRun "grep \"(before open) selinux_status_updated -1\" res.txt"
aba7ab1
        
aba7ab1
        rlRun "grep \"selinux_status_open 0\" res.txt"
aba7ab1
        rlRun "grep \"selinux_status_getenforce $(cat $SELINUX_MNT/enforce)\" res.txt"
aba7ab1
        rlRun "grep -E \"selinux_status_policyload [0-9]\" res.txt"
aba7ab1
        rlRun "grep \"selinux_status_deny_unknown $(cat $SELINUX_MNT/deny_unknown)\" res.txt"
aba7ab1
        rlRun "grep \"selinux_status_updated 0\" res.txt"
aba7ab1
        rlRun "grep \"selinux_status_close void\" res.txt"
aba7ab1
    rlPhaseEnd
aba7ab1
aba7ab1
    rlPhaseStartCleanup
aba7ab1
        rlRun "rm -f test"
aba7ab1
    rlPhaseEnd
aba7ab1
rlJournalPrintText
aba7ab1
rlJournalEnd