"Fossies" - the Fresh Open Source Software Archive

Member "inotify-tools-3.20.11.0/t/inotifywait-format-option-cookie.t" (13 Nov 2020, 1138 Bytes) of package /linux/privat/inotify-tools-3.20.11.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 test_description='Resolves Issue #72
    4 
    5 Make transaction id (cookie) available as part of the format string using %c'
    6 
    7 . ./sharness.sh
    8 
    9 logfile="log"
   10 
   11 run_() {
   12   # Setup code, defer an ATTRIB event for after
   13   # inotifywait has been set up.
   14   touch $logfile
   15 
   16   export LD_LIBRARY_PATH="../../libinotifytools/src/.libs/"
   17 
   18   ../../src/.libs/inotifywait \
   19     --monitor \
   20     --daemon \
   21     --quiet \
   22     --outfile $logfile \
   23     --format '%c %e %w%f' \
   24     --event create \
   25     --event moved_to \
   26     --event moved_from \
   27     $(realpath ./)
   28 
   29   PID="$!"
   30 
   31   touch test-file-src
   32 
   33   mv test-file-src test-file-dst
   34 
   35   kill ${PID}
   36 }
   37 
   38 test_expect_success \
   39     'event logged' \
   40     '
   41     set -e
   42     trap "set +e" RETURN
   43     run_
   44     local NONCOOKIE="$(cat "${logfile}" | sed -n 1p | grep -Eo "^[^ ]+")"
   45     #Make sure cookie is 0 for single events
   46         [[ "${NONCOOKIE}" == "0" ]] || return 1
   47     local COOKIE_A="$(cat "${logfile}" | sed -n 2p | grep -Eo "^[^ ]+")"
   48         [[ -n "${COOKIE_A}" ]] || return 1
   49         local COOKIE_B="$(cat "${logfile}" | sed -n 3p | grep -Eo "^[^ ]+")"
   50         [[ "${COOKIE_A}" == "${COOKIE_B}" ]] || return 1
   51         return 0
   52     '
   53 
   54 test_done