64591e7
#!/bin/bash
64591e7
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
64591e7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64591e7
#
64591e7
#   Description: memfd_create test
64591e7
#   Author: Shu Wang <shuwang@redhat.com>
64591e7
#
64591e7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64591e7
#
64591e7
#   Copyright (c) 2016 Red Hat, Inc.
64591e7
#
64591e7
#   This program is free software: you can redistribute it and/or
64591e7
#   modify it under the terms of the GNU General Public License as
64591e7
#   published by the Free Software Foundation, either version 2 of
64591e7
#   the License, or (at your option) any later version.
64591e7
#
64591e7
#   This program is distributed in the hope that it will be
64591e7
#   useful, but WITHOUT ANY WARRANTY; without even the implied
64591e7
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
64591e7
#   PURPOSE.  See the GNU General Public License for more details.
64591e7
#
64591e7
#   You should have received a copy of the GNU General Public License
64591e7
#   along with this program. If not, see http://www.gnu.org/licenses/.
64591e7
#
64591e7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64591e7
64591e7
# Include Beaker environment
64591e7
. /usr/bin/rhts-environment.sh || exit 1
64591e7
. /usr/share/beakerlib/beakerlib.sh || exit 1
64591e7
64591e7
gcc t_memfd_create.c -o t_memfd_create &&
64591e7
gcc t_get_seals.c -o t_get_seals
64591e7
if [ $? != 0 ]; then
64591e7
    rlLog "memfd_create is not supported."
64591e7
    report_result Test_Skipped PASS 99
64591e7
    exit 0
64591e7
fi
64591e7
64591e7
function sanity_memfd_create()
64591e7
{
64591e7
    rlRun "./t_memfd_create memf 1024 gswS &"
64591e7
    rlRun "./t_get_seals /proc/$!/fd/3 > seals"
64591e7
    rlRun "cat ./seals"
64591e7
    rlAssertGrep "SEAL GROW WRITE SHRINK" ./seals
64591e7
    rlRun "pkill t_memfd_create"
64591e7
}
64591e7
64591e7
64591e7
rlJournalStart
64591e7
    rlPhaseStartTest "sanity"
64591e7
        sanity_memfd_create
64591e7
    rlPhaseEnd
64591e7
rlJournalEnd
64591e7
rlJournalPrintText