#!/bin/sh
# lsb_release-tc.sh  

tet_startup="startup"			# startup function
tet_cleanup="cleanup"                   # cleanup function
iclist="ic1 ic2"
ic1="tp1 tp2"

tp1()
{
        tpstart "Reference 15.1, An LSB conforming implementation shall provide lsb_release."
        tet_infoline "Spec reference: 15.1. Commands and Utilities"
        command -V lsb_release  >out.stdout 2>out.stderr
        check_exit_value $? 0 
        tpresult                        # set result code
}

tp2()
{
        tpstart "Reference 15.2, The lsb_release command should return the version of LSB against which the distribution is compliant."
        tet_infoline "Spec reference: 15.2. Command Behavior"
        tet_infoline "Expecting at least 2 core-$LSB_RELEASE_VER results from lsb_release"
        command lsb_release | awk -f lsb_release.awk >out.stderr 2>out.stderr
        check_exit_value $? 0
        tpresult                        # set result code
}

startup() # startup function
{
     tet_infoline "Prep: Check for awk binary"
     if [ ! -x /bin/awk ] && [ ! -x /usr/bin/awk ]
     then 
         FAIL=Y
     fi
     tet_infoline "Prep: Check for sed binary"
     if [ ! -x /bin/sed ] && [ ! -x /usr/bin/sed ]
     then 
         FAIL=Y
     fi
     if [ "$FAIL" = "Y" ]
     then
          for testcasename in tp1 tp2
          do
               tet_delete $testcasename "awk and/or sed binary is not present"
          done
          return
     fi
     tet_infoline "Prep: Set awk test script to use $LSB_RELEASE_VER"
     command sed -i "s|FIXME|$LSB_RELEASE_VER|g" lsb_release.awk >out.stderr 2>out.stderr
     check_exit_value $? 0 

}

cleanup() # clean-up function
{
     tet_infoline "Cleanup: Restore awk test script to default 'FIXME'"
     command sed -i "s|$LSB_RELEASE_VER|FIXME|g" lsb_release.awk >out.stderr 2>out.stderr
    rm -f out.stdout out.stderr >/dev/null 2>&1
}


# source common shell functions

. $TET_EXECUTE/LIB/shfuncs.sh
. $TET_EXECUTE/LIB/lsbfuncs.sh

# execute shell test case manager - must be last line
. $TET_ROOT/lib/xpg3sh/tcm.sh
