Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.142.172.190
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/share/doc/ucf/examples/ucf_helper_functions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

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:


Anon7 - 2022
AnonSec Team