├── .github ├── CODEOWNERS ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── enhancement-idea.md │ └── support-request.md ├── PULL_REQUEST_TEMPLATE.md ├── SECURITY.md └── workflows │ ├── build-qa-arch-matrix.yml │ ├── build-qa-config-matrix-large.yml │ ├── build-qa-config-matrix-small.yml │ ├── build-qa-os-matrix-large.yml │ ├── build-qa-os-matrix-small.yml │ ├── build-qa-out-of-tree-build.yml │ ├── build-qa-verify-make-targets-prefix.yml │ ├── code-qa-autoscan.yml │ ├── code-qa-codeql.yml │ ├── code-qa-coverity.yml │ ├── code-qa-sonarcloud.yml │ ├── code-qa-valgrind.yml │ ├── install-qa-installfile.yml │ ├── install-qa-os-matrix.yml │ ├── install-qa-readme.yml │ ├── packaging-qa-os-matrix-large.yml │ ├── packaging-qa-os-matrix-small.yml │ ├── publish-native-packages.yml │ ├── release-qa-os-matrix-install-from-repo.yml │ └── release-qa-os-matrix-install-from-source.yml ├── .gitignore ├── COPYING ├── ChangeLog ├── Makefile.am ├── README.md ├── bootstrap.sh ├── build ├── Makefile.am.common └── snoopy.m4 ├── configure.ac ├── configure.scan ├── dev-tools ├── _bootstrap.sh ├── autoscan.sh ├── build-native-package.sh ├── build-release-package.sh ├── clean-git-repository.sh ├── create-release-commit-and-tag.sh ├── import-external-lib.sh ├── install-dev-software.sh ├── install-packaging-software.sh ├── libexec │ ├── extract-and-run-install-steps-from-readme.sh │ ├── extract-native-package-install-steps.sh │ ├── generate-gcov-reports.sh │ ├── get-random-configure-flags.sh │ ├── get-release-tag.sh │ ├── get-release-version.sh │ ├── get-sonarcloud-tag.sh │ ├── verify-last-version-everywhere.sh │ ├── verify-last-version-in-changelog.sh │ ├── verify-last-version-in-readme.sh │ └── verify-make-targets-prefix.sh ├── publish-native-package.sh ├── publish-release.sh ├── submit-to-coverity.conf.SAMPLE ├── submit-to-coverity.sh ├── submit-to-sonarcloud.conf.SAMPLE ├── submit-to-sonarcloud.sh └── test-build-matrix.sh ├── doc ├── CONTRIBUTING.md ├── DOCKER-BASED-ISSUE-DEMO-Dockerfile ├── DOCKER-BASED-ISSUE-DEMO.md ├── FAQ.md ├── FILTER_exclude_spawns_of.md ├── GETTING-SUPPORT.md ├── HACKING-INTERNALS.md ├── HACKING-OVERVIEW.md ├── HACKING-QA.md ├── INSTALL-MULTIARCH.md ├── INSTALL.md ├── Makefile.am ├── RELEASING-HOWTO.md ├── install-from-repo.md └── install-from-source.md ├── etc ├── Makefile.am └── snoopy.ini.in ├── install └── install-snoopy.sh ├── lib ├── Makefile.am └── inih │ ├── IMPORT.defs │ ├── LICENSE │ ├── Makefile.am │ ├── patches │ ├── 0001-strip-value-quotes.diff │ ├── 0002-prefix-function-names.diff │ └── 0003-fix-double-cast.diff │ └── src │ ├── Makefile.am │ ├── ini.c │ └── ini.h ├── packaging ├── arch │ ├── PKGBUILD │ ├── env │ └── snoopy.install ├── deb │ ├── README.Build.md │ ├── README.Debian │ ├── README.md │ ├── changelog.TEMPLATE │ ├── compat │ ├── control │ ├── copyright │ ├── extra-files │ │ └── snapd-apparmor-profile │ ├── rules │ ├── snoopy.config │ ├── snoopy.docs │ ├── snoopy.lintian-overrides │ ├── snoopy.postinst │ ├── snoopy.prerm │ ├── source.lintian-overrides │ ├── source │ │ └── format │ └── templates └── rpm │ ├── README.md │ └── snoopy.spec ├── src ├── Makefile.am ├── action │ ├── Makefile.am │ ├── log-message-dispatch.c │ ├── log-message-dispatch.h │ ├── log-syscall-exec.c │ └── log-syscall-exec.h ├── cli │ ├── Makefile.am │ ├── action-conf.c │ ├── action-conf.h │ ├── action-disable.c │ ├── action-disable.h │ ├── action-enable.c │ ├── action-enable.h │ ├── action-status.c │ ├── action-status.h │ ├── action-version.c │ ├── action-version.h │ ├── cli-subroutines.c │ ├── cli-subroutines.h │ └── snoopyctl.c ├── configfile.c ├── configfile.h ├── configuration.c ├── configuration.h ├── datasource │ ├── Makefile.am │ ├── cgroup.c │ ├── cgroup.h │ ├── cmdline.c │ ├── cmdline.h │ ├── cwd.c │ ├── cwd.h │ ├── datasource-common.h │ ├── datetime.c │ ├── datetime.h │ ├── domain.c │ ├── domain.h │ ├── egid.c │ ├── egid.h │ ├── egroup.c │ ├── egroup.h │ ├── env.c │ ├── env.h │ ├── env_all.c │ ├── env_all.h │ ├── euid.c │ ├── euid.h │ ├── eusername.c │ ├── eusername.h │ ├── failure.c │ ├── failure.h │ ├── filename.c │ ├── filename.h │ ├── gid.c │ ├── gid.h │ ├── group.c │ ├── group.h │ ├── hostname.c │ ├── hostname.h │ ├── ipaddr.c │ ├── ipaddr.h │ ├── login.c │ ├── login.h │ ├── noop.c │ ├── noop.h │ ├── pid.c │ ├── pid.h │ ├── ppid.c │ ├── ppid.h │ ├── rpname.c │ ├── rpname.h │ ├── sid.c │ ├── sid.h │ ├── snoopy_configure_command.c │ ├── snoopy_configure_command.h │ ├── snoopy_literal.c │ ├── snoopy_literal.h │ ├── snoopy_threads.c │ ├── snoopy_threads.h │ ├── snoopy_version.c │ ├── snoopy_version.h │ ├── systemd-unit-name.c │ ├── systemd-unit-name.h │ ├── tid.c │ ├── tid.h │ ├── tid_kernel.c │ ├── tid_kernel.h │ ├── timestamp.c │ ├── timestamp.h │ ├── timestamp_ms.c │ ├── timestamp_ms.h │ ├── timestamp_us.c │ ├── timestamp_us.h │ ├── tty.c │ ├── tty.h │ ├── tty__common.c │ ├── tty__common.h │ ├── tty_uid.c │ ├── tty_uid.h │ ├── tty_username.c │ ├── tty_username.h │ ├── uid.c │ ├── uid.h │ ├── username.c │ └── username.h ├── datasourceregistry.c ├── datasourceregistry.h ├── entrypoint │ ├── Makefile.am │ ├── cli.c │ ├── cli.h │ ├── execve-wrapper-test-configfile-env.c │ ├── execve-wrapper-test-configfile-env.h │ ├── execve-wrapper.c │ ├── execve-wrapper.h │ ├── test-cli.c │ └── test-cli.h ├── error.c ├── error.h ├── filter │ ├── Makefile.am │ ├── exclude_spawns_of.c │ ├── exclude_spawns_of.h │ ├── exclude_uid.c │ ├── exclude_uid.h │ ├── noop.c │ ├── noop.h │ ├── only_root.c │ ├── only_root.h │ ├── only_tty.c │ ├── only_tty.h │ ├── only_uid.c │ └── only_uid.h ├── filtering.c ├── filtering.h ├── filterregistry.c ├── filterregistry.h ├── genericregistry.c ├── genericregistry.h ├── init-deinit.c ├── init-deinit.h ├── inputdatastorage.c ├── inputdatastorage.h ├── message.c ├── message.h ├── output │ ├── Makefile.am │ ├── devlogoutput.c │ ├── devlogoutput.h │ ├── devnulloutput.c │ ├── devnulloutput.h │ ├── devttyoutput.c │ ├── devttyoutput.h │ ├── fileoutput.c │ ├── fileoutput.h │ ├── noopoutput.c │ ├── noopoutput.h │ ├── socketoutput.c │ ├── socketoutput.h │ ├── stderroutput.c │ ├── stderroutput.h │ ├── stdoutoutput.c │ ├── stdoutoutput.h │ ├── syslogoutput.c │ └── syslogoutput.h ├── outputregistry.c ├── outputregistry.h ├── snoopy.h ├── tsrm.c ├── tsrm.h └── util │ ├── Makefile.am │ ├── file-snoopy.h │ ├── file.c │ ├── list-snoopy.h │ ├── list.c │ ├── parser-snoopy.h │ ├── parser.c │ ├── pwd-snoopy.h │ ├── pwd.c │ ├── string-snoopy.h │ ├── string.c │ ├── syslog-snoopy.h │ ├── syslog.c │ ├── systemd-snoopy.h │ ├── systemd.c │ ├── utmp-snoopy.h │ └── utmp.c └── tests ├── Makefile.am ├── _bootstrap-paths.sh.in ├── _bootstrap.sh ├── bin ├── Makefile.am ├── action-common.h ├── action-run-configfile.c ├── action-run-configfile.h ├── action-run-datasource.c ├── action-run-datasource.h ├── action-run-everything.c ├── action-run-everything.h ├── action-run-filter.c ├── action-run-filter.h ├── action-run-filterchain.c ├── action-run-filterchain.h ├── action-run-messageformat.c ├── action-run-messageformat.h ├── action-run-output.c ├── action-run-output.h ├── action-run.c ├── action-run.h ├── action-stress-threads.c ├── action-stress-threads.h ├── action-stress-threadsexec.c ├── action-stress-threadsexec.h ├── action-stress.c ├── action-stress.h ├── action-unit-action-log-message-dispatch.c ├── action-unit-action-log-message-dispatch.h ├── action-unit-action-log-syscall-exec.c ├── action-unit-action-log-syscall-exec.h ├── action-unit-action.c ├── action-unit-action.h ├── action-unit-datasource-cmdline.c ├── action-unit-datasource-cmdline.h ├── action-unit-datasource.c ├── action-unit-datasource.h ├── action-unit-error.c ├── action-unit-error.h ├── action-unit-ext-ini.c ├── action-unit-ext-ini.h ├── action-unit-filterregistry.c ├── action-unit-filterregistry.h ├── action-unit-outputregistry.c ├── action-unit-outputregistry.h ├── action-unit-util-parser.c ├── action-unit-util-parser.h ├── action-unit-util-syslog.c ├── action-unit-util-syslog.h ├── action-unit-util-systemd.c ├── action-unit-util-systemd.h ├── action-unit-util-utmp.c ├── action-unit-util-utmp.h ├── action-unit-util.c ├── action-unit-util.h ├── action-unit.c ├── action-unit.h ├── snoopy-test.c └── spaceparent.c ├── cli ├── Makefile.am ├── _bootstrap.sh ├── cli-action-about.sh ├── cli-action-conf.sh ├── cli-action-disable-1-nofile.sh ├── cli-action-disable-2-emptyfile.sh ├── cli-action-disable-31-only-entry.sh ├── cli-action-disable-32-only-entry-no-newline.sh ├── cli-action-disable-33-only-entry-and-space.sh ├── cli-action-disable-34-only-entry-and-tab.sh ├── cli-action-disable-35-only-entry-and-comment.sh ├── cli-action-disable-41-first.sh ├── cli-action-disable-42-middle.sh ├── cli-action-disable-43-last.sh ├── cli-action-disable-44-last-no-newline.sh ├── cli-action-disable-45-after-identical-comment.sh ├── cli-action-disable-51-dupe-mine.sh ├── cli-action-disable-52-dupe-alien.sh ├── cli-action-disable-53-dupe-mixed.sh ├── cli-action-enable-1-nofile.sh ├── cli-action-enable-2-emptyfile.sh ├── cli-action-enable-31-non-empty.sh ├── cli-action-enable-32-non-empty-no-newline.sh ├── cli-action-enable-45-after-identical-comment.sh ├── cli-action-enable-51-already-enabled.sh ├── cli-action-enable-52-another-instance-enabled.sh ├── cli-action-help.sh ├── cli-action-status-LD_PRELOAD-absent.sh ├── cli-action-status-LD_PRELOAD-present.sh ├── cli-action-status-LD_PRELOAD-set-but-not-present.sh ├── cli-action-status-ld.so.preload-absent.sh ├── cli-action-status-ld.so.preload-alien.sh ├── cli-action-status-ld.so.preload-dupe.sh ├── cli-action-status-ld.so.preload-present.sh ├── cli-action-version-cli.sh ├── cli-action-version-library.sh ├── cli-err-action-missing-msg.sh ├── cli-err-action-missing-status.sh ├── cli-err-action-unknown-msg.sh └── cli-err-action-unknown-status.sh ├── combined ├── Makefile.am ├── _bootstrap.sh ├── combined-filter-exclude_uid-drop.sh ├── combined-filter-exclude_uid-pass.sh ├── combined-filter-only_uid-drop.sh ├── combined-filter-only_uid-pass.sh ├── combined-generic.sh ├── combined-nofilter-1.sh └── combined-nofilter-2.sh ├── configfile ├── Makefile.am ├── _bootstrap.sh ├── configfile-bom.sh ├── configfile-datasource_message_max_length-min.sh ├── configfile-datasource_message_max_length-purenumeric.sh ├── configfile-datasource_message_max_length-suffix-k.sh ├── configfile-datasource_message_max_length-suffix-m-max.sh ├── configfile-error_logging-n1.sh ├── configfile-error_logging-n2.sh ├── configfile-error_logging-n3.sh ├── configfile-error_logging-y1.sh ├── configfile-error_logging-y2.sh ├── configfile-error_logging-y3.sh ├── configfile-filter_chain-1.sh ├── configfile-generic.sh ├── configfile-inline-comment.sh ├── configfile-line-length-1023.sh ├── configfile-line-length-1024.sh ├── configfile-log_message_max_length-min.sh ├── configfile-log_message_max_length-purenumeric.sh ├── configfile-log_message_max_length-suffix-k.sh ├── configfile-log_message_max_length-suffix-m-max.sh ├── configfile-message_format-1.sh ├── configfile-message_format-double-quoted.sh ├── configfile-message_format-single-quoted.sh ├── configfile-message_format-unquoted.sh ├── configfile-output-devlog.sh ├── configfile-output-file.sh ├── configfile-output-invalid.sh ├── configfile-output-socket.sh ├── configfile-syslog_facility.sh ├── configfile-syslog_ident.sh └── configfile-syslog_level.sh ├── datasource ├── Makefile.am ├── _bootstrap.sh ├── datasource_cgroup-name-first.sh ├── datasource_cgroup-name-last.sh ├── datasource_cgroup-name-mid.sh ├── datasource_cgroup-name-notfound.sh ├── datasource_cgroup-name.sh ├── datasource_cgroup-number-notfound.sh ├── datasource_cgroup-number.sh ├── datasource_cmdline.sh ├── datasource_cwd.sh ├── datasource_datetime-fmt-epoch.sh ├── datasource_datetime-fmt-static.sh ├── datasource_datetime-fmt-too-long.sh ├── datasource_datetime-fmt-ymd.sh ├── datasource_datetime.sh ├── datasource_domain.sh ├── datasource_egid.sh ├── datasource_egroup.sh ├── datasource_env-set.sh ├── datasource_env-unset.sh ├── datasource_env_all.sh ├── datasource_euid.sh ├── datasource_eusername.sh ├── datasource_failure.sh ├── datasource_filename.sh ├── datasource_gid.sh ├── datasource_group.sh ├── datasource_hostname.sh ├── datasource_ipaddr.sh ├── datasource_login.sh ├── datasource_pid.sh ├── datasource_ppid.sh ├── datasource_rpname.sh ├── datasource_sid.sh ├── datasource_snoopy_configure_command.sh ├── datasource_snoopy_literal.sh ├── datasource_snoopy_threads.sh ├── datasource_snoopy_version.sh ├── datasource_systemd_unit_name.sh ├── datasource_tid.sh ├── datasource_tid_kernel.sh ├── datasource_timestamp.sh ├── datasource_timestamp_ms.sh ├── datasource_timestamp_us.sh ├── datasource_tty.sh ├── datasource_tty_uid.sh ├── datasource_tty_username.sh ├── datasource_uid.sh └── datasource_username.sh ├── filter ├── Makefile.am ├── _bootstrap.sh ├── filter_exclude_spawns_of-mustdrop-multiarg-first.sh ├── filter_exclude_spawns_of-mustdrop-multiarg-last.sh ├── filter_exclude_spawns_of-mustdrop-multiarg-mid.sh ├── filter_exclude_spawns_of-mustdrop-singlearg.sh ├── filter_exclude_spawns_of-mustdrop-spaceparent.sh ├── filter_exclude_spawns_of-mustlog-multiarg.sh ├── filter_exclude_spawns_of-mustlog-singlearg.sh ├── filter_exclude_spawns_of-mustlog-spaceparent.sh ├── filter_exclude_uid-drop-multi.sh ├── filter_exclude_uid-drop.sh ├── filter_exclude_uid-pass-multi.sh ├── filter_exclude_uid-pass.sh ├── filter_only_tty.sh ├── filter_only_uid-drop-multi.sh ├── filter_only_uid-drop.sh ├── filter_only_uid-pass-multi.sh ├── filter_only_uid-pass.sh ├── filterchain-double-bothdrop.sh ├── filterchain-double-bothpass.sh ├── filterchain-double-firstdrops.sh ├── filterchain-double-seconddrops.sh ├── filterchain-single-drop.sh ├── filterchain-single-pass.sh ├── filterchain-trailing-semicolon-drop.sh ├── filterchain-trailing-semicolon-pass.sh └── filterchain-unknown-filter.sh ├── general ├── Makefile.am ├── _bootstrap.sh └── general-symbol-leaks.sh ├── message ├── Makefile.am ├── _bootstrap.sh ├── message_format-datasource-arg.sh ├── message_format-datasource-noarg.sh ├── message_format-ds-closing-tag-missing.sh ├── message_format-ds-failure.sh ├── message_format-ds-unknown.sh ├── message_format-empty.sh └── message_format-static.sh ├── output ├── Makefile.am ├── _bootstrap.sh ├── output_devnull.sh ├── output_file-dynamic-arg.sh ├── output_file-dynamic.sh ├── output_file.sh ├── output_noop.sh ├── output_socket.sh ├── output_stderr.sh └── output_stdout.sh ├── threads ├── Makefile.am ├── _bootstrap.sh ├── threads_creation.sh ├── threads_fork_exec.sh └── threads_try-to-segfault.sh └── unit ├── Makefile.am ├── _bootstrap.sh ├── unit-action-log-message-dispatch.sh ├── unit-action-log-syscall-exec.sh ├── unit-datasource-cmdline.sh ├── unit-error.sh ├── unit-ext-ini.sh ├── unit-filterregistry.sh ├── unit-outputregistry.sh ├── unit-util-parser.sh ├── unit-util-syslog.sh ├── unit-util-systemd.sh ├── unit-util-utmp-entry-missing.sh ├── unit-util-utmp-entry-without-ip-address.sh ├── unit-util-utmp-ipv4.sh ├── unit-util-utmp-ipv6.sh └── unit-util-utmp-testUtmpFile /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @bostjan 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://flattr.com/@bostjan'] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement-idea.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement idea 3 | about: Suggest a new feature for Snoopy 4 | title: '' 5 | labels: 'Type: Enhancement' 6 | assignees: '' 7 | --- 8 | 9 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Only the latest stable Snoopy release is supported. Bugfixes will not be backported to older releases. 6 | The latest Snoopy version can be found: 7 | - In the [main README.md](https://github.com/a2o/snoopy) file, or 8 | - In the [releases](https://github.com/a2o/snoopy/releases) section. 9 | 10 | 11 | ## Reporting a Vulnerability 12 | 13 | Report a security-related issue like any other issue, in Snoopy's [issue tracker](https://github.com/a2o/snoopy/issues), as a `Bug`. 14 | -------------------------------------------------------------------------------- /dev-tools/autoscan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Shell configuration and script bootstrap 6 | # 7 | set -e 8 | set -u 9 | set -o pipefail 10 | . `dirname $0`/_bootstrap.sh 11 | 12 | 13 | 14 | ### Run autoscan 15 | # 16 | autoscan 17 | 18 | 19 | 20 | ### Fix the autoscan's output 21 | # 22 | # AC_CONFIG_SRCDIR is somewhat randomly set to the first encountered file in the source tree. 23 | # 24 | # Enountered so far: 25 | # - lib/inih/src/ini.h (long time default) 26 | # - lib/inih/src/ini.c (encountered in 2023 on Ubuntu 20.04) 27 | # - tests/bin/action-run-filter.c (encountered in GitHub's Actions) 28 | # 29 | # Let's just stop this nonsense and fix the output manually. 30 | # 31 | sed -i 's%^AC_CONFIG_SRCDIR.\+%# AC_CONFIG_SRCDIR commented out by dev-tools/autoscan.sh%' configure.scan 32 | -------------------------------------------------------------------------------- /dev-tools/libexec/generate-gcov-reports.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Shell configuration and script bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $0`/../_bootstrap.sh 10 | 11 | 12 | 13 | ### Generate reports 14 | # 15 | for CFILE in `find . -name '*.c' | sort`; do 16 | CDIR=`dirname "$CFILE"` 17 | CFILENAME=`basename $CFILE` 18 | CFILENAME_NOEXT=`echo "$CFILENAME" | sed -e 's/\.c$//'` 19 | if [ -f $CDIR/$CFILENAME_NOEXT.gcno ]; then 20 | GCNO_FILE="$CFILENAME_NOEXT.gcno" 21 | elif [ -f $CDIR/.libs/$CFILENAME_NOEXT.gcno ]; then 22 | GCNO_FILE=".libs/$CFILENAME_NOEXT.gcno" 23 | else 24 | echo "ERROR: Cannot locate .gcno file for $CFILE ($CDIR, $CFILENAME, $CFILENAME_NOEXT), exiting." 25 | exit 1 26 | fi 27 | echo "Generating coverage analysis for $CFILE (from $GCNO_FILE)..." 28 | ( 29 | cd $CDIR && 30 | gcov $GCNO_FILE 31 | ) 32 | done 33 | -------------------------------------------------------------------------------- /dev-tools/libexec/verify-make-targets-prefix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Shell configuration and script bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $0`/../_bootstrap.sh 10 | 11 | 12 | 13 | ### Generate reports 14 | # 15 | RES=`make -p | grep -Eo '^[a-z][^:]+\.lo:' | grep -E '^libsnoopy' -c || true` 16 | if [ "$RES" -ne "0" ]; then 17 | make -p | grep -Eo '^[a-z][^:]+\.lo:' | grep -E '^libsnoopy' 18 | _fatalError "Some *.lo make targets contain 'libsnoopy...' prefix (listed above)." $LINENO 19 | fi 20 | 21 | 22 | 23 | ### All good 24 | # 25 | _echo "All relevant make targets do not contain 'libsnoopy...' prefix, good." 26 | -------------------------------------------------------------------------------- /dev-tools/submit-to-coverity.conf.SAMPLE: -------------------------------------------------------------------------------- 1 | COVERITY_EMAIL=`git config user.email` 2 | COVERITY_TOKEN="" 3 | COVERITY_BUILD_VERSION=`./dev-tools/libexec/get-release-version.sh` 4 | -------------------------------------------------------------------------------- /dev-tools/submit-to-sonarcloud.conf.SAMPLE: -------------------------------------------------------------------------------- 1 | SONAR_TOKEN="" 2 | -------------------------------------------------------------------------------- /doc/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Snoopy development 2 | 3 | Contents of this file have been moved to [.github](../.github/) folder, reason being that 4 | when done so, GitHub displays link to contributing guidelines when creating 5 | a new issue or submitting a pull request. 6 | 7 | Direct links to relevant documents: 8 | * [../.github/CONTRIBUTING.md](../.github/CONTRIBUTING.md) 9 | * [../.github/PULL_REQUEST_TEMPLATE.md](../.github/PULL_REQUEST_TEMPLATE.md) 10 | * [../.github/ISSUE_TEMPLATE.md](../.github/ISSUE_TEMPLATE.md) 11 | * [HACKING-OVERVIEW.md](HACKING-OVERVIEW.md) 12 | * [HACKING-INTERNALS.md](HACKING-INTERNALS.md) 13 | * [HACKING-QA.md](HACKING-QA.md) 14 | -------------------------------------------------------------------------------- /doc/DOCKER-BASED-ISSUE-DEMO-Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jrei/systemd-ubuntu:20.04 2 | 3 | ENV container docker 4 | ENV LC_ALL C 5 | ENV DEBIAN_FRONTEND noninteractive 6 | 7 | # Install Snoopy-installation prerequisites 8 | RUN apt-get update 9 | RUN apt-get install -y wget 10 | 11 | # Install Snoopy 12 | RUN wget -O install-snoopy.sh https://github.com/a2o/snoopy/raw/install/install/install-snoopy.sh \ 13 | && chmod 755 install-snoopy.sh \ 14 | && ./install-snoopy.sh stable 15 | 16 | # Define systemd as the default command 17 | ENTRYPOINT ["/lib/systemd/systemd"] 18 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Include documentation in final release package 8 | # 9 | EXTRA_DIST = \ 10 | CONTRIBUTING.md \ 11 | FAQ.md \ 12 | FILTER_exclude_spawns_of.md \ 13 | INSTALL.md 14 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | SUBDIRS = 5 | 6 | 7 | ### INI file parser 8 | # 9 | if CONFIGFILE_ENABLED 10 | SUBDIRS += inih 11 | endif 12 | -------------------------------------------------------------------------------- /lib/inih/IMPORT.defs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -u 5 | 6 | EXTLIB_GIT_REPO_URL="https://github.com/benhoyt/inih.git" 7 | EXTLIB_GIT_REF="tags/r55-0-gf7f69c6" 8 | 9 | _snoopy_extlib_import() 10 | { 11 | SRCDIR="$1" 12 | DESTDIR="$2" 13 | 14 | cp $SRCDIR/LICENSE.txt $DESTDIR/LICENSE 15 | cp $SRCDIR/ini.c $DESTDIR/src/ini.c 16 | cp $SRCDIR/ini.h $DESTDIR/src/ini.h 17 | } 18 | -------------------------------------------------------------------------------- /lib/inih/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Subdir processing order 8 | # 9 | SUBDIRS = 10 | SUBDIRS += src 11 | -------------------------------------------------------------------------------- /lib/inih/patches/0001-strip-value-quotes.diff: -------------------------------------------------------------------------------- 1 | --- src/ini.c.ORIG 2020-11-12 23:40:31.773490733 +0100 2 | +++ src/ini.c 2020-11-12 23:41:06.825555329 +0100 3 | @@ -209,6 +209,17 @@ 4 | value = lskip(value); 5 | rstrip(value); 6 | 7 | + /* Strip surrounding double and single quotes */ 8 | + if ((*value == '"') && (value[strlen(value) - 1] == '"')) { 9 | + value[strlen(value) - 1] = '\0'; 10 | + value += 1; 11 | + } else { 12 | + if ((*value == '\'') && (value[strlen(value) - 1] == '\'')) { 13 | + value[strlen(value) - 1] = '\0'; 14 | + value += 1; 15 | + } 16 | + } 17 | + 18 | /* Valid name[=:]value pair found, call handler */ 19 | strncpy0(prev_name, name, sizeof(prev_name)); 20 | if (!HANDLER(user, section, name, value) && !error) 21 | -------------------------------------------------------------------------------- /lib/inih/patches/0002-prefix-function-names.diff: -------------------------------------------------------------------------------- 1 | --- src/ini.h.ORIG 2020-11-26 03:37:52.533640594 +0100 2 | +++ src/ini.h 2020-11-26 03:38:43.553738846 +0100 3 | @@ -14,6 +14,13 @@ 4 | #ifndef INI_H 5 | #define INI_H 6 | 7 | +/* START For Snoopy - redefine function names, to avoid symbol name collisions */ 8 | +#define ini_parse snoopy_ini_parse 9 | +#define ini_parse_file snoopy_ini_parse_file 10 | +#define ini_parse_stream snoopy_ini_parse_stream 11 | +#define ini_parse_string snoopy_ini_parse_string 12 | +/* END For Snoopy */ 13 | + 14 | /* Make this header file easier to include in C++ code */ 15 | #ifdef __cplusplus 16 | extern "C" { 17 | -------------------------------------------------------------------------------- /lib/inih/patches/0003-fix-double-cast.diff: -------------------------------------------------------------------------------- 1 | --- src/ini.c 2 | +++ src/ini.c 3 | @@ -100,7 +100,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, 4 | /* Uses a fair bit of stack (use heap instead if you need to) */ 5 | #if INI_USE_STACK 6 | char line[INI_MAX_LINE]; 7 | - int max_line = INI_MAX_LINE; 8 | + size_t max_line = INI_MAX_LINE; 9 | #else 10 | char* line; 11 | size_t max_line = INI_INITIAL_ALLOC; 12 | -------------------------------------------------------------------------------- /lib/inih/src/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Override certain inih defaults 8 | # 9 | AM_CFLAGS += -DINI_MAX_LINE=1024 -DINI_INITIAL_ALLOC=1024 '-DINI_API=__attribute__((visibility("hidden")))' 10 | 11 | 12 | 13 | ### Create library "libinih" 14 | # 15 | noinst_LTLIBRARIES = \ 16 | libinih.la 17 | 18 | libinih_la_SOURCES = \ 19 | ini.c \ 20 | ini.h 21 | -------------------------------------------------------------------------------- /packaging/arch/env: -------------------------------------------------------------------------------- 1 | # 2 | # Environment variables, consumed by dev-tools/build-package-arch.sh 3 | # 4 | if [ "${PACKAGER:-}" == "" ]; then 5 | export PACKAGER="Bostjan Skufca Jese " 6 | fi 7 | -------------------------------------------------------------------------------- /packaging/arch/snoopy.install: -------------------------------------------------------------------------------- 1 | post_install() { 2 | /usr/bin/snoopyctl enable 3 | } 4 | 5 | pre_remove() { 6 | /usr/bin/snoopyctl disable 7 | } 8 | -------------------------------------------------------------------------------- /packaging/deb/README.Build.md: -------------------------------------------------------------------------------- 1 | # Snoopy Command Logger - DEB packaging 2 | 3 | Consult the [packaging/deb/README.md](README.md) file in Snoopy's Git repository for up-to-date .deb package building instructions. 4 | -------------------------------------------------------------------------------- /packaging/deb/README.md: -------------------------------------------------------------------------------- 1 | # Snoopy Command Logger - DEB packaging 2 | 3 | ## Info 4 | 5 | The provided [packaging/debian](.) directory is not configured to be used directly, nor in a standalone fashion. 6 | It only works when used within this Git repository, and with the provided tooling. 7 | 8 | 9 | 10 | ## How to build a DEB package 11 | 12 | Steps: 13 | - Clone this Git repository onto a supported system, 14 | - Install the required development and packaging tools, and 15 | - Use the package building script. 16 | 17 | To clone this repository: 18 | ``` 19 | git clone https://github.com/a2o/snoopy 20 | cd snoopy 21 | ``` 22 | 23 | To install the required software (this only needs to be done once): 24 | ```bash 25 | ./dev-tools/install-dev-software.sh 26 | ./dev-tools/install-packaging-software.sh 27 | ``` 28 | 29 | To build a DEB package: 30 | ```bash 31 | ./dev-tools/build-package-deb.sh 32 | ``` 33 | 34 | Done. 35 | -------------------------------------------------------------------------------- /packaging/deb/changelog.TEMPLATE: -------------------------------------------------------------------------------- 1 | snoopy (DEB_PACKAGE_VERSION) unstable; urgency=medium 2 | 3 | * NOTICE: This is not a real changelog. 4 | * This .deb package has been provided by Snoopy maintainers. 5 | * Snoopy's git repository is the actual changelog for this package, 6 | at https://github.com/a2o/snoopy/. 7 | * NOTICE: While the intent of Snoopy maintainers is to keep their 8 | .deb packages in sync and interchangeable with distribution-provided 9 | Snoopy packages, the packaging efforts are not synchronized and thus 10 | incompatible differences may occur. 11 | * NOTICE: To build the .deb package yourself, use the provided 12 | ./dev-tools/build-package-deb.sh helper script. 13 | * NOTICE: To install the required software for building the .deb 14 | package, use the provided ./dev-tools/install-packaging-software.sh 15 | helper script. 16 | 17 | -- Bostjan Skufca Jese Sat, 06 Aug 2022 00:00:00 +0000 18 | -------------------------------------------------------------------------------- /packaging/deb/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /packaging/deb/extra-files/snapd-apparmor-profile: -------------------------------------------------------------------------------- 1 | # 2 | # Ubuntu Snap AppArmor profile additions by Snoopy Command Logger 3 | # 4 | # Snoopy installation from .deb currently does not reload apparmor profiles. 5 | # You will either need to do that manually, or reboot the whole system. 6 | # 7 | # Additionally, once "inside" snap, Snoopy is unable to read /etc/snoopy.ini 8 | # on the host's filesystem, which makes it revert back to the built-in default 9 | # configuration. 10 | # 11 | /lib/x86_64-linux-gnu/libsnoopy.so* mr, 12 | /etc/snoopy.ini r, 13 | 14 | /dev/pts/ r, 15 | /proc/*/loginuid r, 16 | /proc/[0-9]+/status r, 17 | /usr/lib/x86_64-linux-gnu/libnss_compat-*.so mr, 18 | /usr/lib/x86_64-linux-gnu/libnss_nis-*.so mr, 19 | /usr/lib/x86_64-linux-gnu/libnsl-*.so mr, 20 | 21 | unix (create, connect, send) type=dgram, 22 | unix (create, connect, send) type=stream, 23 | 24 | /dev/log w, 25 | /run/systemd/journal/dev-log w, 26 | /var/log/snoopy.log w, 27 | -------------------------------------------------------------------------------- /packaging/deb/snoopy.config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | PRELOAD="/etc/ld.so.preload" 6 | LIBNAME="libsnoopy.so" 7 | 8 | . /usr/share/debconf/confmodule 9 | 10 | [ -n "$SNOOPYDEBUG" ] && set -x 11 | 12 | db_input critical snoopy/install-ld-preload || true 13 | db_go 14 | -------------------------------------------------------------------------------- /packaging/deb/snoopy.docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /packaging/deb/snoopy.lintian-overrides: -------------------------------------------------------------------------------- 1 | # This package is not a library intended to build executables against 2 | # nor to be linked by any application. 3 | 4 | snoopy: link-to-shared-library-in-wrong-package 5 | snoopy: package-name-doesnt-match-sonames 6 | snoopy: no-symbols-control-file lib/*/libsnoopy.so.0.0.0 7 | -------------------------------------------------------------------------------- /packaging/deb/snoopy.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | . /usr/share/debconf/confmodule 6 | 7 | case "$1" in 8 | configure) 9 | db_get snoopy/install-ld-preload 10 | if [ x"$RET" = x"true" ] ; then 11 | /usr/sbin/snoopyctl enable 12 | fi 13 | ;; 14 | 15 | abort-upgrade|abort-remove|abort-deconfigure) 16 | ;; 17 | 18 | *) 19 | echo "postinst called with unknown argument \`$1'" >&2 20 | exit 1 21 | ;; 22 | esac 23 | 24 | #DEBHELPER# 25 | 26 | exit 0 27 | -------------------------------------------------------------------------------- /packaging/deb/snoopy.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | remove|upgrade|deconfigure) 7 | /usr/sbin/snoopyctl disable 8 | ;; 9 | 10 | failed-upgrade) 11 | ;; 12 | 13 | *) 14 | echo "prerm called with unknown argument \`$1'" >&2 15 | exit 1 16 | ;; 17 | esac 18 | 19 | #DEBHELPER# 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /packaging/deb/source.lintian-overrides: -------------------------------------------------------------------------------- 1 | snoopy source: native-package-with-dash-version 2 | snoopy source: maintainer-address-malformed Sébastien Gross 3 | -------------------------------------------------------------------------------- /packaging/deb/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (git) 2 | -------------------------------------------------------------------------------- /packaging/deb/templates: -------------------------------------------------------------------------------- 1 | Template: snoopy/install-ld-preload 2 | Type: boolean 3 | Default: false 4 | Description: Install Snoopy library to /etc/ld.so.preload? 5 | Snoopy is a library that can only reliably do its work if it is 6 | mandatorily preloaded via /etc/ld.so.preload. Since this can potentially 7 | do harm to the system, your consent is needed. 8 | -------------------------------------------------------------------------------- /packaging/rpm/README.md: -------------------------------------------------------------------------------- 1 | # Snoopy Command Logger - RPM packaging 2 | 3 | ## Info 4 | 5 | The provided [snoopy.spec](snoopy.spec) file is not configured to be used directly, nor in a standalone fashion. 6 | It only works when used within this Git repository, and with the provided tooling. 7 | 8 | 9 | 10 | ## How to build a RPM package 11 | 12 | Steps: 13 | - Clone this Git repository onto a supported system, 14 | - Install the required development and packaging tools, and 15 | - Use the package building script. 16 | 17 | To clone this repository: 18 | ``` 19 | git clone https://github.com/a2o/snoopy 20 | cd snoopy 21 | ``` 22 | 23 | To install the required software (this only needs to be done once): 24 | ```bash 25 | ./dev-tools/install-dev-software.sh 26 | ./dev-tools/install-packaging-software.sh 27 | ``` 28 | 29 | To build a RPM package: 30 | ```bash 31 | ./dev-tools/build-package-rpm.sh 32 | ``` 33 | 34 | Done. 35 | -------------------------------------------------------------------------------- /src/action/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Temporary library to build 8 | # 9 | noinst_LTLIBRARIES = libsnoopy-actions-all.la 10 | libsnoopy_actions_all_la_SOURCES = \ 11 | log-message-dispatch.c \ 12 | log-message-dispatch.h \ 13 | log-syscall-exec.c \ 14 | log-syscall-exec.h 15 | libsnoopy_actions_all_la_LDFLAGS = 16 | -------------------------------------------------------------------------------- /src/action/log-message-dispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2014 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | /* 24 | * Log message dispatching action 25 | */ 26 | int snoopy_action_log_message_dispatch (const char *logMessage); 27 | -------------------------------------------------------------------------------- /src/action/log-syscall-exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: log.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | void snoopy_action_log_syscall_exec (); 26 | -------------------------------------------------------------------------------- /src/cli/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Variables to add final targets to 8 | # 9 | noinst_LTLIBRARIES = 10 | sbin_PROGRAMS = 11 | 12 | 13 | 14 | ### Build subroutines separately, it gets linked into `snoopy-test` too 15 | # 16 | noinst_LTLIBRARIES += libsnoopy-cli-subroutines.la 17 | libsnoopy_cli_subroutines_la_SOURCES = \ 18 | cli-subroutines.c \ 19 | cli-subroutines.h 20 | 21 | 22 | 23 | ### Program-based entry points 24 | # 25 | sbin_PROGRAMS += snoopyctl 26 | snoopyctl_SOURCES = \ 27 | action-conf.c \ 28 | action-conf.h \ 29 | action-disable.c \ 30 | action-disable.h \ 31 | action-enable.c \ 32 | action-enable.h \ 33 | action-status.c \ 34 | action-status.h \ 35 | action-version.c \ 36 | action-version.h \ 37 | snoopyctl.c 38 | snoopyctl_LDADD = \ 39 | libsnoopy-cli-subroutines.la \ 40 | ../util/libsnoopy-utils.la 41 | -------------------------------------------------------------------------------- /src/cli/action-conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopy_cli_action_conf (); 24 | -------------------------------------------------------------------------------- /src/cli/action-disable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2020 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopy_cli_action_disable (); 24 | -------------------------------------------------------------------------------- /src/cli/action-enable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2020 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopy_cli_action_enable (); 24 | -------------------------------------------------------------------------------- /src/cli/action-status.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2020 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopy_cli_action_status (); 24 | -------------------------------------------------------------------------------- /src/cli/action-version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2020 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopy_cli_action_version (); 24 | -------------------------------------------------------------------------------- /src/datasource/cgroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | #include "datasource-common.h" 24 | 25 | 26 | 27 | /* 28 | * SNOOPY DATA SOURCE: cgroup 29 | */ 30 | int snoopy_datasource_cgroup (char * const resultBuf, size_t resultBufSize, char const * const arg); 31 | -------------------------------------------------------------------------------- /src/datasource/datasource-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/datasource/datasource-common.h 5 | * 6 | * Copyright (c) 2023 Bostjan Skufca Jese 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* Required for size_t type */ 26 | #include 27 | -------------------------------------------------------------------------------- /src/datasource/ipaddr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | #include "datasource-common.h" 24 | 25 | 26 | 27 | int snoopy_datasource_ipaddr (char * const resultBuf, size_t resultBufSize, char const * const arg); 28 | -------------------------------------------------------------------------------- /src/datasource/pid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/datasource/pid.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | #include "datasource-common.h" 26 | 27 | 28 | 29 | /* 30 | * SNOOPY DATA SOURCE: pid 31 | */ 32 | int snoopy_datasource_pid (char * const resultBuf, size_t resultBufSize, char const * const arg); 33 | -------------------------------------------------------------------------------- /src/datasource/systemd-unit-name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | #include "datasource-common.h" 24 | 25 | 26 | 27 | /* 28 | * SNOOPY DATA SOURCE: systemd_unit_name 29 | */ 30 | int snoopy_datasource_systemd_unit_name (char * const resultBuf, size_t resultBufSize, char const * const arg); 31 | -------------------------------------------------------------------------------- /src/entrypoint/cli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | void snoopy_entrypoint_cli_init (); 24 | void snoopy_entrypoint_cli_exit (); 25 | -------------------------------------------------------------------------------- /src/entrypoint/test-cli.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | void snoopy_entrypoint_test_cli_init (const char *filename, char *const argv[], char * const configFilePath); 24 | void snoopy_entrypoint_test_cli_threads_init(); 25 | void snoopy_entrypoint_test_cli_exit (); 26 | -------------------------------------------------------------------------------- /src/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: error.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * Error-handling functions 27 | */ 28 | void snoopy_error_handler (char const * const errorMsg); 29 | -------------------------------------------------------------------------------- /src/filter/exclude_spawns_of.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/filter/exclude_spawns_of.h 5 | * 6 | * Copyright (c) 2015 Datto, Inc. All rights reserved. 7 | * Author: Fred Mora - fmora@datto.com 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2, or (at your option) 12 | * any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software Foundation, 21 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 | */ 23 | 24 | 25 | 26 | /* 27 | * SNOOPY FILTER: exclude_spawns_of 28 | */ 29 | int snoopy_filter_exclude_spawns_of (char const * const arg); 30 | -------------------------------------------------------------------------------- /src/filter/exclude_uid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/filter/exclude_uid.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY FILTER: exclude_uid 27 | */ 28 | int snoopy_filter_exclude_uid (char const * const arg); 29 | -------------------------------------------------------------------------------- /src/filter/noop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/datasource/noop.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY FILTER: noop 27 | */ 28 | int snoopy_filter_noop (char const * const arg); 29 | -------------------------------------------------------------------------------- /src/filter/only_root.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/filter/only_root.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY FILTER: only_root 27 | */ 28 | int snoopy_filter_only_root (char const * const arg); 29 | -------------------------------------------------------------------------------- /src/filter/only_uid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/filter/only_uid.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY FILTER: only_uid 27 | */ 28 | int snoopy_filter_only_uid (char const * const arg); 29 | -------------------------------------------------------------------------------- /src/filtering.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: filtering.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | int snoopy_filtering_check_chain (char const * const chain); 26 | -------------------------------------------------------------------------------- /src/init-deinit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2014-2015 Bostjan Skufca 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | void snoopy_init (); 24 | void snoopy_cleanup (); 25 | -------------------------------------------------------------------------------- /src/output/devlogoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/devlogoutput.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: directly to /dev/log 27 | */ 28 | int snoopy_output_devlogoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/devnulloutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/devnulloutput.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: directly to /dev/tty 27 | */ 28 | int snoopy_output_devnulloutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/devttyoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/devttyoutput.h 5 | * 6 | * Copyright (c) 2014-2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: directly to /dev/tty 27 | */ 28 | int snoopy_output_devttyoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/fileoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/fileoutput.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: write directly to file 27 | */ 28 | int snoopy_output_fileoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/noopoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/noopoutput.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: noop 27 | */ 28 | int snoopy_output_noopoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/socketoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/socketoutput.h 5 | * 6 | * Copyright (c) 2014 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: socket 27 | */ 28 | int snoopy_output_socketoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/stderroutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/stderroutput.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: write to stderr 27 | */ 28 | int snoopy_output_stderroutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/stdoutoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/stdoutoutput.h 5 | * 6 | * Copyright (c) 2015 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: write to stdout 27 | */ 28 | int snoopy_output_stdoutoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/output/syslogoutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * File: snoopy/output/syslogoutput.h 5 | * 6 | * Copyright (c) 2014 Bostjan Skufca (bostjan _A_T_ a2o.si) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | */ 22 | 23 | 24 | 25 | /* 26 | * SNOOPY OUTPUT: syslog 27 | */ 28 | int snoopy_output_syslogoutput (char const * const logMessage, char const * const arg); 29 | -------------------------------------------------------------------------------- /src/util/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Create one library with all Snoopy utils collected in it 8 | # 9 | # Maintain alphabetical order, equal to what `ls` would do. 10 | # 11 | noinst_LTLIBRARIES = libsnoopy-utils.la 12 | libsnoopy_utils_la_SOURCES = \ 13 | file.c \ 14 | file-snoopy.h \ 15 | parser.c \ 16 | parser-snoopy.h \ 17 | pwd.c \ 18 | pwd-snoopy.h \ 19 | string.c \ 20 | string-snoopy.h \ 21 | syslog.c \ 22 | syslog-snoopy.h 23 | 24 | 25 | if DATASOURCE_ENABLED_ipaddr 26 | libsnoopy_utils_la_SOURCES += \ 27 | utmp.c \ 28 | utmp-snoopy.h 29 | endif 30 | 31 | 32 | if DATASOURCE_ENABLED_systemd_unit_name 33 | libsnoopy_utils_la_SOURCES += \ 34 | systemd.c \ 35 | systemd-snoopy.h 36 | endif 37 | 38 | 39 | if THREAD_SAFETY_ENABLED 40 | libsnoopy_utils_la_SOURCES += \ 41 | list.c \ 42 | list-snoopy.h 43 | endif 44 | -------------------------------------------------------------------------------- /src/util/pwd-snoopy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese (bostjan _A_T_ a2o.si) 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | #include "snoopy.h" 24 | 25 | #include 26 | 27 | 28 | 29 | char * snoopy_util_pwd_convertUidToUsername (uid_t uid); 30 | -------------------------------------------------------------------------------- /src/util/systemd-snoopy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese (bostjan _A_T_ a2o.si) 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | char * snoopy_util_systemd_convertCgroupEntryToUnitName (char const * const cgroupEntry); 24 | char * snoopy_util_systemd_convertUserSliceInfoToUsername (char const * const userSliceInfo); 25 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Subdir processing order 8 | # 9 | SUBDIRS = 10 | 11 | SUBDIRS += bin 12 | SUBDIRS += cli 13 | if CONFIGFILE_ENABLED 14 | SUBDIRS += configfile 15 | endif 16 | SUBDIRS += datasource 17 | if FILTERING_ENABLED 18 | SUBDIRS += filter 19 | endif 20 | SUBDIRS += general 21 | SUBDIRS += message 22 | SUBDIRS += output 23 | if THREAD_SAFETY_ENABLED 24 | SUBDIRS += threads 25 | endif 26 | SUBDIRS += unit 27 | # 28 | # Functional tests at last 29 | # 30 | if CONFIGFILE_ENABLED 31 | if DATASOURCE_ENABLED_cmdline 32 | if OUTPUT_ENABLED_file 33 | SUBDIRS += combined 34 | endif 35 | endif 36 | endif 37 | 38 | 39 | 40 | ### Include these files too 41 | # 42 | EXTRA_DIST = 43 | EXTRA_DIST += _bootstrap.sh 44 | EXTRA_DIST += _bootstrap-paths.sh 45 | 46 | 47 | 48 | ### Clean all test leftovers 49 | # 50 | # These are usually left behind when we rename files 51 | # 52 | clean-local-this-dir: 53 | rm -f */*.log ; 54 | rm -f */*.trs ; 55 | -------------------------------------------------------------------------------- /tests/_bootstrap-paths.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Get variables from the build system 13 | # 14 | SNOOPY_LIBDIR="@SNOOPY_LIBDIR@" 15 | LIBSNOOPY_SO_PATH="$SNOOPY_LIBDIR/libsnoopy.so" 16 | -------------------------------------------------------------------------------- /tests/bin/action-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | #include "cli/cli-subroutines.h" 24 | 25 | 26 | 27 | extern int g_argc; 28 | extern char ** g_argv; 29 | -------------------------------------------------------------------------------- /tests/bin/action-run-configfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run_configfile (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-run-datasource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | #include 24 | 25 | 26 | 27 | int snoopyTestCli_action_run_datasource (int argc, char ** argv); 28 | void snoopyTestCli_action_run_datasource_all (size_t datasource_message_max_length); 29 | -------------------------------------------------------------------------------- /tests/bin/action-run-everything.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run_everything (); 24 | -------------------------------------------------------------------------------- /tests/bin/action-run-filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run_filter (int argc, char ** argv); 24 | void snoopyTestCli_action_run_filter_all (); 25 | -------------------------------------------------------------------------------- /tests/bin/action-run-filterchain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run_filterchain (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-run-messageformat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run_messageformat (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-run-output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run_output (int argc, char ** argv); 24 | void snoopyTestCli_action_run_output_all (); 25 | -------------------------------------------------------------------------------- /tests/bin/action-run.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_run (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-stress-threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_stress_threads (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-stress-threadsexec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_stress_threadsexec (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-stress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_stress (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-action-log-message-dispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_action_log_message_dispatch (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-action-log-syscall-exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_action_log_syscall_exec (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-action.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_action (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-datasource-cmdline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_datasource_cmdline (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-datasource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_datasource (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_error (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-ext-ini.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_ext_ini (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-filterregistry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_filterregistry (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-outputregistry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_outputregistry (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-util-parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_util_parser (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-util-syslog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_util_syslog (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-util-systemd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_util_systemd (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-util-utmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_util_utmp (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit_util (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/action-unit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SNOOPY COMMAND LOGGER 3 | * 4 | * Copyright (c) 2022 Bostjan Skufca Jese 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | 22 | 23 | int snoopyTestCli_action_unit (int argc, char ** argv); 24 | -------------------------------------------------------------------------------- /tests/bin/spaceparent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include /* for fork */ 5 | #include /* for pid_t */ 6 | #include /* for wait */ 7 | 8 | int main (int argc, char **argv) 9 | { 10 | if (argc < 2) { 11 | printf("Pass command to run as an argument: \"./space parent\" /cmd/to/run [args]\n"); 12 | exit(1); 13 | } 14 | 15 | /* Spawn a child to run the program. */ 16 | pid_t pid = fork(); 17 | if (pid == -1) { /* fork failed */ 18 | printf("fork() failed\n"); 19 | exit(2); 20 | } 21 | 22 | if (pid == 0) { /* child process */ 23 | execv(argv[1], &argv[1]); 24 | 25 | /* This only gets executed if execv fails */ 26 | printf("execv() failed\n"); 27 | exit(3); 28 | 29 | } else { /* pid!=0; parent process */ 30 | int status; 31 | waitpid(pid, &status, 0); /* wait for child to exit */ 32 | if (status != 0) { 33 | printf("Child regurned with a non-zero status: %d\n", status); 34 | exit(4); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/cli/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | 16 | 17 | 18 | ### This dir-specific settings 19 | # 20 | # Path to the freshly built `snoopyctl` CLI tool 21 | export SNOOPY_CLI="$SNOOPY_CUR_TEST_WORKDIR/../../src/cli/snoopyctl" 22 | # This one changes the behaviour of `snoopyctl ...` CLI tool, to look for `libsnoopy.so` 23 | # in the specified location instead of the configured one. 24 | # For now, this does not change what `snoopyctl enable` puts into the `ld.so.preload` file. 25 | export SNOOPY_TEST_LIBSNOOPY_SO_PATH="$SNOOPY_CUR_TEST_WORKDIR/../../src/.libs/libsnoopy.so" 26 | -------------------------------------------------------------------------------- /tests/cli/cli-action-about.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | EXPECTED_STRING="https://github.com/a2o/snoopy" 16 | if ! $SNOOPY_CLI about | fgrep "$EXPECTED_STRING" > /dev/null ; then 17 | snoopy_testResult_fail "Expected string not encountered: '$EXPECTED_STRING'" 18 | fi 19 | 20 | 21 | 22 | ### Evaluate 23 | # 24 | snoopy_testResult_pass 25 | -------------------------------------------------------------------------------- /tests/cli/cli-action-conf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | EXPECTED_STRING="message_format" 16 | if ! $SNOOPY_CLI conf | fgrep "$EXPECTED_STRING" > /dev/null ; then 17 | snoopy_testResult_fail "Expected string not encountered: '$EXPECTED_STRING'" 18 | fi 19 | 20 | 21 | 22 | ### Evaluate 23 | # 24 | snoopy_testResult_pass 25 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-1-nofile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | 18 | 19 | 20 | ### Run the command 21 | # 22 | $SNOOPY_CLI disable 23 | 24 | 25 | 26 | ### Evaluate 27 | # 28 | if [ -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 29 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly appeared" 30 | fi 31 | 32 | snoopy_testResult_pass 33 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-2-emptyfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | touch $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI disable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if [ ! -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly missing" 31 | fi 32 | 33 | FILESIZE=`stat -c "%s" $SNOOPY_TEST_LD_SO_PRELOAD_PATH` 34 | if [ "$FILESIZE" != "0" ]; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly non-empty" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-31-only-entry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI disable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if [ ! -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly missing" 31 | fi 32 | 33 | FILESIZE=`stat -c "%s" $SNOOPY_TEST_LD_SO_PRELOAD_PATH` 34 | if [ "$FILESIZE" != "0" ]; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly non-empty" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-32-only-entry-no-newline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo -n "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI disable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if [ ! -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly missing" 31 | fi 32 | 33 | FILESIZE=`stat -c "%s" $SNOOPY_TEST_LD_SO_PRELOAD_PATH` 34 | if [ "$FILESIZE" != "0" ]; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly non-empty" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-33-only-entry-and-space.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH # comment" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI disable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if [ ! -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly missing" 31 | fi 32 | 33 | FILESIZE=`stat -c "%s" $SNOOPY_TEST_LD_SO_PRELOAD_PATH` 34 | if [ "$FILESIZE" != "0" ]; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly non-empty" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-34-only-entry-and-tab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH # comment" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI disable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if [ ! -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly missing" 31 | fi 32 | 33 | FILESIZE=`stat -c "%s" $SNOOPY_TEST_LD_SO_PRELOAD_PATH` 34 | if [ "$FILESIZE" != "0" ]; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly non-empty" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-35-only-entry-and-comment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH# comment" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI disable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if [ ! -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH ]; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly missing" 31 | fi 32 | 33 | FILESIZE=`stat -c "%s" $SNOOPY_TEST_LD_SO_PRELOAD_PATH` 34 | if [ "$FILESIZE" != "0" ]; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) unexpectedly non-empty" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-41-first.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH 18 | # asdf 19 | # bsdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 20 | echo "# asdf 21 | # bsdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 22 | 23 | 24 | 25 | ### Run the command 26 | # 27 | $SNOOPY_CLI disable 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 34 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 35 | fi 36 | 37 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-42-middle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "# asdf 18 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH 19 | # bsdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 20 | echo "# asdf 21 | # bsdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 22 | 23 | 24 | 25 | ### Run the command 26 | # 27 | $SNOOPY_CLI disable 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 34 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 35 | fi 36 | 37 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-43-last.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "# asdf 18 | # bsdf 19 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 20 | echo "# asdf 21 | # bsdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 22 | 23 | 24 | 25 | ### Run the command 26 | # 27 | $SNOOPY_CLI disable 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 34 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 35 | fi 36 | 37 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-44-last-no-newline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo -n "# asdf 18 | # bsdf 19 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 20 | echo -n "# asdf 21 | # bsdf 22 | " > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 23 | 24 | 25 | 26 | ### Run the command 27 | # 28 | $SNOOPY_CLI disable 29 | 30 | 31 | 32 | ### Evaluate 33 | # 34 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 40 | snoopy_testResult_pass 41 | -------------------------------------------------------------------------------- /tests/cli/cli-action-disable-45-after-identical-comment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo -n "# asdf 18 | # $SNOOPY_TEST_LIBSNOOPY_SO_PATH 19 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 20 | echo -n "# asdf 21 | # $SNOOPY_TEST_LIBSNOOPY_SO_PATH 22 | " > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 23 | 24 | 25 | 26 | ### Run the command 27 | # 28 | $SNOOPY_CLI disable 29 | 30 | 31 | 32 | ### Evaluate 33 | # 34 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 35 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 36 | fi 37 | 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 39 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 40 | snoopy_testResult_pass 41 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-1-nofile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 18 | 19 | 20 | 21 | ### Run the command 22 | # 23 | $SNOOPY_CLI enable 24 | 25 | 26 | 27 | ### Evaluate 28 | # 29 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 30 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 31 | fi 32 | 33 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 34 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 35 | 36 | snoopy_testResult_pass 37 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-2-emptyfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | touch $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 19 | 20 | 21 | 22 | ### Run the command 23 | # 24 | $SNOOPY_CLI enable 25 | 26 | 27 | 28 | ### Evaluate 29 | # 30 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 31 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 32 | fi 33 | 34 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 35 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 36 | 37 | snoopy_testResult_pass 38 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-31-non-empty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "# asdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | echo "# asdf 19 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 20 | 21 | 22 | 23 | ### Run the command 24 | # 25 | $SNOOPY_CLI enable 26 | 27 | 28 | 29 | ### Evaluate 30 | # 31 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 32 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 33 | fi 34 | 35 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 36 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 37 | 38 | snoopy_testResult_pass 39 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-32-non-empty-no-newline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo -n "# asdf" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | echo "# asdf 19 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 20 | 21 | 22 | 23 | ### Run the command 24 | # 25 | $SNOOPY_CLI enable 26 | 27 | 28 | 29 | ### Evaluate 30 | # 31 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 32 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 33 | fi 34 | 35 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 36 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 37 | 38 | snoopy_testResult_pass 39 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-45-after-identical-comment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "# asdf 18 | # $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 19 | echo "# asdf 20 | # $SNOOPY_TEST_LIBSNOOPY_SO_PATH 21 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 22 | 23 | 24 | 25 | ### Run the command 26 | # 27 | $SNOOPY_CLI enable 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 34 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 35 | fi 36 | 37 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 38 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 39 | 40 | snoopy_testResult_pass 41 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-51-already-enabled.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 19 | 20 | 21 | 22 | ### Run the command 23 | # 24 | $SNOOPY_CLI enable 25 | 26 | 27 | 28 | ### Evaluate 29 | # 30 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 31 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 32 | fi 33 | 34 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 35 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 36 | 37 | snoopy_testResult_pass 38 | -------------------------------------------------------------------------------- /tests/cli/cli-action-enable-52-another-instance-enabled.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Setup the test environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "/another/instance/of/libsnoopy.so" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | echo "/another/instance/of/libsnoopy.so" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 19 | 20 | 21 | 22 | ### Run the command & test the exit status 23 | # 24 | if $SNOOPY_CLI enable ; then 25 | snoopy_testResult_fail "Unexpected zero exit status" 26 | fi 27 | 28 | 29 | 30 | ### Evaluate 31 | # 32 | if ! diff -u $SNOOPY_TEST_LD_SO_PRELOAD_PATH $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result ; then 33 | snoopy_testResult_fail "ld.so.preload test file ($SNOOPY_TEST_LD_SO_PRELOAD_PATH) content not as expected" 34 | fi 35 | 36 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 37 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH.expected-result 38 | 39 | snoopy_testResult_pass 40 | -------------------------------------------------------------------------------- /tests/cli/cli-action-help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | EXPECTED_STRING="Available actions:" 16 | if ! $SNOOPY_CLI help | fgrep "$EXPECTED_STRING" > /dev/null ; then 17 | snoopy_testResult_fail "Expected string not encountered: '$EXPECTED_STRING'" 18 | fi 19 | 20 | 21 | 22 | ### Success 23 | # 24 | snoopy_testResult_pass 25 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-LD_PRELOAD-absent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | unset LD_PRELOAD 17 | 18 | 19 | 20 | ### Execute & verify 21 | # 22 | if ! $SNOOPY_CLI status 2>&1 | grep -E '^LD_PRELOAD environment var: +NOT OK - Not set' > /dev/null ; then 23 | snoopy_testResult_fail "LD_PRELOAD unset, but status says otherwise" 24 | fi 25 | 26 | 27 | 28 | ### Success 29 | # 30 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 31 | snoopy_testResult_pass 32 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-LD_PRELOAD-present.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | export LD_PRELOAD="$SNOOPY_TEST_LIBSNOOPY_SO_PATH" 17 | 18 | 19 | 20 | ### Execute & verify 21 | # 22 | if ! $SNOOPY_CLI status 2>&1 | grep -E '^LD_PRELOAD environment var: +OK - Snoopy reference found.' > /dev/null ; then 23 | snoopy_testResult_fail "LD_PRELOAD contains valid libsnoopy.so reference, but status says otherwise" 24 | fi 25 | 26 | 27 | 28 | ### Success 29 | # 30 | snoopy_testResult_pass 31 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-LD_PRELOAD-set-but-not-present.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | export LD_PRELOAD="" 17 | 18 | 19 | 20 | ### Execute & verify 21 | # 22 | if ! $SNOOPY_CLI status 2>&1 | grep -E '^LD_PRELOAD environment var: +NOT SET - Set, but no Snoopy reference found' > /dev/null ; then 23 | snoopy_testResult_fail "LD_PRELOAD set but does not contain a valid libsnoopy.so reference, yet status says otherwise" 24 | fi 25 | 26 | 27 | 28 | ### Success 29 | # 30 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 31 | snoopy_testResult_pass 32 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-ld.so.preload-absent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "# something random in here" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Execute & verify 22 | # 23 | if ! $SNOOPY_CLI status 2>&1 | grep -E '^/etc/ld.so.preload: +NOT OK - Snoopy is not enabled' > /dev/null ; then 24 | snoopy_testResult_fail "ld.so.preload does not contain a valid libsnoopy.so reference, but status says otherwise" 25 | fi 26 | 27 | 28 | 29 | ### Success 30 | # 31 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 32 | snoopy_testResult_pass 33 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-ld.so.preload-alien.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "/unknown/lib/$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Execute & verify 22 | # 23 | if ! $SNOOPY_CLI status 2>&1 | grep -E "^/etc/ld.so.preload: +NOT OK - 'libsnoopy.so' found, but not with the expected path" > /dev/null ; then 24 | snoopy_testResult_fail "ld.so.preload contains invalid libsnoopy.so reference, but status error message not as expected" 25 | fi 26 | 27 | 28 | 29 | ### Success 30 | # 31 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 32 | snoopy_testResult_pass 33 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-ld.so.preload-dupe.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH 18 | $SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 19 | 20 | 21 | 22 | ### Execute & verify 23 | # 24 | if $SNOOPY_CLI status > /dev/null ; then 25 | snoopy_testResult_fail "ld.so.preload contains duplicate libsnoopy.so reference, but status didn't fail" 26 | fi 27 | 28 | 29 | 30 | ### Success 31 | # 32 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 33 | snoopy_testResult_pass 34 | -------------------------------------------------------------------------------- /tests/cli/cli-action-status-ld.so.preload-present.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Prepare the environment 14 | # 15 | export SNOOPY_TEST_LD_SO_PRELOAD_PATH="$SNOOPY_CUR_TEST_FILENAME.ld.so.preload" 16 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 17 | echo "$SNOOPY_TEST_LIBSNOOPY_SO_PATH" > $SNOOPY_TEST_LD_SO_PRELOAD_PATH 18 | 19 | 20 | 21 | ### Execute & verify 22 | # 23 | if ! $SNOOPY_CLI status 2>&1 | grep -E '^/etc/ld.so.preload: +OK - Snoopy is enabled.' > /dev/null ; then 24 | snoopy_testResult_fail "ld.so.preload contains valid libsnoopy.so reference, but status says otherwise" 25 | fi 26 | 27 | 28 | 29 | ### Success 30 | # 31 | rm -f $SNOOPY_TEST_LD_SO_PRELOAD_PATH 32 | snoopy_testResult_pass 33 | -------------------------------------------------------------------------------- /tests/cli/cli-action-version-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | SEARCH_REGEX="^Snoopy CLI tool version: [-.a-z0-9]+" 16 | if ! $SNOOPY_CLI version | grep -E "$SEARCH_REGEX" > /dev/null ; then 17 | snoopy_testResult_fail "Unable to find expected version information: $SEARCH_REGEX" 18 | fi 19 | 20 | 21 | 22 | ### Success 23 | # 24 | snoopy_testResult_pass 25 | -------------------------------------------------------------------------------- /tests/cli/cli-action-version-library.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | SEARCH_REGEX="^Snoopy library version: [-.a-z0-9]+" 16 | if ! $SNOOPY_CLI version | grep -E "$SEARCH_REGEX" > /dev/null ; then 17 | snoopy_testResult_fail "Unable to find expected version information: $SEARCH_REGEX" 18 | fi 19 | 20 | 21 | 22 | ### Success 23 | # 24 | snoopy_testResult_pass 25 | -------------------------------------------------------------------------------- /tests/cli/cli-err-action-missing-msg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | EXPECTED_ERROR_MESSAGE="[ERROR] No action specified" 16 | RES=`$SNOOPY_CLI 2>&1 | fgrep -c "$EXPECTED_ERROR_MESSAGE"` || true 17 | if [ "$RES" != "1" ]; then 18 | snoopy_testResult_fail "Expected error message not encountered: '$EXPECTED_ERROR_MESSAGE'" 19 | fi 20 | 21 | 22 | 23 | ### Success 24 | # 25 | snoopy_testResult_pass 26 | -------------------------------------------------------------------------------- /tests/cli/cli-err-action-missing-status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | if $SNOOPY_CLI > /dev/null 2>&1 ; then 16 | snoopy_testResult_fail "Expected non-zero exit status" 17 | fi 18 | 19 | 20 | 21 | ### Success 22 | # 23 | snoopy_testResult_pass 24 | -------------------------------------------------------------------------------- /tests/cli/cli-err-action-unknown-msg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | ACTION="sampleUnknownAction" 16 | EXPECTED_ERROR_MESSAGE="[ERROR] Unknown action: $ACTION" 17 | RES=`$SNOOPY_CLI $ACTION 2>&1 | fgrep -c "$EXPECTED_ERROR_MESSAGE"` || true 18 | if [ "$RES" != "1" ]; then 19 | snoopy_testResult_fail "Expected error message not encountered: '$EXPECTED_ERROR_MESSAGE'" 20 | fi 21 | 22 | 23 | 24 | ### Success 25 | # 26 | snoopy_testResult_pass 27 | -------------------------------------------------------------------------------- /tests/cli/cli-err-action-unknown-status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Test for error(s) 14 | # 15 | if $SNOOPY_CLI sampleUnknownAction > /dev/null 2>&1 ; then 16 | snoopy_testResult_fail "Expected non-zero exit status" 17 | fi 18 | 19 | 20 | 21 | ### Success 22 | # 23 | snoopy_testResult_pass 24 | -------------------------------------------------------------------------------- /tests/combined/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Which tests to run 8 | # 9 | TESTS = 10 | XFAIL_TESTS = 11 | 12 | TESTS += combined-nofilter-1.sh 13 | TESTS += combined-nofilter-2.sh 14 | 15 | if FILTERING_ENABLED 16 | if FILTER_ENABLED_exclude_uid 17 | TESTS += combined-filter-exclude_uid-drop.sh 18 | TESTS += combined-filter-exclude_uid-pass.sh 19 | endif 20 | if FILTER_ENABLED_only_uid 21 | TESTS += combined-filter-only_uid-drop.sh 22 | TESTS += combined-filter-only_uid-pass.sh 23 | endif 24 | endif 25 | 26 | 27 | 28 | ### Include tests in distribution archive 29 | # 30 | EXTRA_DIST = _bootstrap.sh 31 | EXTRA_DIST += combined-generic.sh 32 | EXTRA_DIST += $(TESTS) 33 | 34 | 35 | 36 | ### Remove stale temporary test files, if tests got stuck 37 | # 38 | clean-local-this-dir: 39 | rm -f *.ini ; 40 | rm -f *.out ; 41 | -------------------------------------------------------------------------------- /tests/combined/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/combined/combined-filter-exclude_uid-drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Set test configuration 13 | # 14 | MY_UID=`id -u` 15 | ARG_1="ls -la /" 16 | ARG_2="%{cmdline}" 17 | ARG_3="exclude_uid:$MY_UID" 18 | ARG_4="0" 19 | ARG_5="" 20 | 21 | 22 | 23 | ### Call/source common combined test implementation 24 | # 25 | . `dirname $BASH_SOURCE`/combined-generic.sh 26 | -------------------------------------------------------------------------------- /tests/combined/combined-filter-exclude_uid-pass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Set test configuration 13 | # 14 | CUR_TIMESTAMP=`date +%s` 15 | MY_UID=`id -u` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | ARG_1="ls -la /" 18 | ARG_2="$CUR_TIMESTAMP %{cmdline}" 19 | ARG_3="exclude_uid:$MY_UID_PLUS_1" 20 | ARG_4="1" 21 | ARG_5="$CUR_TIMESTAMP ls -la /" 22 | 23 | 24 | 25 | ### Call/source common combined test implementation 26 | # 27 | . `dirname $BASH_SOURCE`/combined-generic.sh 28 | -------------------------------------------------------------------------------- /tests/combined/combined-filter-only_uid-drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Set test configuration 13 | # 14 | MY_UID=`id -u` 15 | MY_UID_PLUS_1=`expr $MY_UID + 1` 16 | ARG_1="ls -la /" 17 | ARG_2="%{cmdline}" 18 | ARG_3="only_uid:$MY_UID_PLUS_1" 19 | ARG_4="0" 20 | ARG_5="" 21 | 22 | 23 | 24 | ### Call/source common combined test implementation 25 | # 26 | . `dirname $BASH_SOURCE`/combined-generic.sh 27 | -------------------------------------------------------------------------------- /tests/combined/combined-filter-only_uid-pass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Set test configuration 13 | # 14 | CUR_TIMESTAMP=`date +%s` 15 | MY_UID=`id -u` 16 | ARG_1="ls -la /" 17 | ARG_2="$CUR_TIMESTAMP %{cmdline}" 18 | ARG_3="only_uid:$MY_UID" 19 | ARG_4="1" 20 | ARG_5="$CUR_TIMESTAMP $ARG_1" 21 | 22 | 23 | 24 | ### Call/source common combined test implementation 25 | # 26 | . `dirname $BASH_SOURCE`/combined-generic.sh 27 | -------------------------------------------------------------------------------- /tests/combined/combined-nofilter-1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Set test configuration 13 | # 14 | ARG_1="ls -la /" 15 | ARG_2="%{cmdline}" 16 | ARG_3="" 17 | ARG_4="1" 18 | ARG_5="ls -la /" 19 | 20 | 21 | 22 | ### Call/source common combined test implementation 23 | # 24 | . `dirname $BASH_SOURCE`/combined-generic.sh 25 | -------------------------------------------------------------------------------- /tests/combined/combined-nofilter-2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Set test configuration 13 | # 14 | ARG_1="ls -la /; ls /" 15 | ARG_2="%{cmdline}" 16 | ARG_3="" 17 | ARG_4="2" 18 | ARG_5=$'ls -la /\nls /' 19 | 20 | 21 | 22 | ### Call/source common combined test implementation 23 | # 24 | . `dirname $BASH_SOURCE`/combined-generic.sh 25 | -------------------------------------------------------------------------------- /tests/configfile/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/configfile/configfile-bom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="someRandomValue" 16 | 17 | TMP_INI=$SNOOPY_CUR_TEST_FILENAME.ini 18 | rm -f $TMP_INI 19 | 20 | echo -e "\xEF\xBB\xBF[snoopy] 21 | message_format = $VAL_REAL" > $TMP_INI 22 | 23 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run configfile "$TMP_INI" "message_format"` 24 | rm -f $TMP_INI 25 | 26 | 27 | 28 | ### Evaluate 29 | # 30 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 31 | -------------------------------------------------------------------------------- /tests/configfile/configfile-datasource_message_max_length-min.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Set parameters 14 | # 15 | CONFIG_VARIABLE="datasource_message_max_length" 16 | VAL_CONF="1" 17 | VAL_EXPECTED="255" 18 | 19 | 20 | 21 | ### Execute generic test 22 | # 23 | $SNOOPY_CUR_TEST_DIR/configfile-generic.sh "$CONFIG_VARIABLE" "$VAL_CONF" "$VAL_EXPECTED" 24 | -------------------------------------------------------------------------------- /tests/configfile/configfile-datasource_message_max_length-purenumeric.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Set parameters 14 | # 15 | CONFIG_VARIABLE="datasource_message_max_length" 16 | VAL_REAL="1511" 17 | 18 | 19 | 20 | ### Execute generic test 21 | # 22 | $SNOOPY_CUR_TEST_DIR/configfile-generic.sh "$CONFIG_VARIABLE" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/configfile/configfile-datasource_message_max_length-suffix-k.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Set parameters 14 | # 15 | CONFIG_VARIABLE="datasource_message_max_length" 16 | VAL_CONF="7k" 17 | VAL_EXPECTED="7168" 18 | 19 | 20 | 21 | ### Execute generic test 22 | # 23 | $SNOOPY_CUR_TEST_DIR/configfile-generic.sh "$CONFIG_VARIABLE" "$VAL_CONF" "$VAL_EXPECTED" 24 | -------------------------------------------------------------------------------- /tests/configfile/configfile-datasource_message_max_length-suffix-m-max.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Set parameters 14 | # 15 | CONFIG_VARIABLE="datasource_message_max_length" 16 | VAL_CONF="1m" 17 | VAL_EXPECTED="1048575" 18 | 19 | 20 | 21 | ### Execute generic test 22 | # 23 | $SNOOPY_CUR_TEST_DIR/configfile-generic.sh "$CONFIG_VARIABLE" "$VAL_CONF" "$VAL_EXPECTED" 24 | -------------------------------------------------------------------------------- /tests/configfile/configfile-error_logging-n1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_INI="n" 16 | VAL_PARSED="n" 17 | 18 | TMP_INI=$SNOOPY_CUR_TEST_FILENAME.ini 19 | rm -f $TMP_INI 20 | 21 | cat > $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < $TMP_INI < /dev/null; then 20 | snoopy_testResult_skip "Cgroup with multiple controllers does not exist" 21 | fi 22 | 23 | 24 | 25 | ### Evaluate 26 | # 27 | CONTROLLER_NAME=`cat /proc/self/cgroup | grep -E '^[0-9]:[^,:]+,[^:]+:' | head -n1 | cut -d: -f2 | cut -d, -f1` 28 | VAL_EXPECTED=`cat /proc/self/cgroup | grep -E "^[0-9]:$CONTROLLER_NAME," | head -n1` 29 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup "$CONTROLLER_NAME"` 30 | 31 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 32 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cgroup-name-last.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Verify the environment 14 | # 15 | if [ ! -f /proc/self/cgroup ]; then 16 | snoopy_testResult_skip "File /proc/self/cgroup does not exist" 17 | fi 18 | 19 | if ! grep -E '^[0-9]:[^,:]+,[^:]+:' /proc/self/cgroup > /dev/null; then 20 | snoopy_testResult_skip "Cgroup with multiple controllers does not exist" 21 | fi 22 | 23 | 24 | 25 | ### Evaluate 26 | # 27 | CONTROLLER_NAME=`cat /proc/self/cgroup | grep -E '^[0-9]:[^:]+,[^:]+:' | head -n1 | cut -d: -f2 | awk -F ',' '{print $NF}'` 28 | VAL_EXPECTED=`cat /proc/self/cgroup | grep -E "^[0-9]:[^:]+,$CONTROLLER_NAME:" | head -n1` 29 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup "$CONTROLLER_NAME"` 30 | 31 | echo $CONTROLLER_NAME 32 | echo $VAL_SNOOPY 33 | echo $VAL_EXPECTED 34 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 35 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cgroup-name-mid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Verify the environment 14 | # 15 | if [ ! -f /proc/self/cgroup ]; then 16 | snoopy_testResult_skip "File /proc/self/cgroup does not exist" 17 | fi 18 | 19 | if ! grep -E '^[0-9]:[^,:]+,[^,:]+,[^:]+:' /proc/self/cgroup > /dev/null; then 20 | snoopy_testResult_skip "Cgroup with more than two controllers does not exist" 21 | fi 22 | 23 | 24 | 25 | ### Evaluate 26 | # 27 | CONTROLLER_NAME=`cat /proc/self/cgroup | grep -E '^[0-9]:[^,:]+,[^,:]+,[^:]+:' | head -n1 | cut -d: -f2 | cut -d, -f2` 28 | VAL_EXPECTED=`cat /proc/self/cgroup | grep -E "^[0-9]:[^,:]+,$CONTROLLER_NAME," | head -n1` 29 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup "$CONTROLLER_NAME"` 30 | 31 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 32 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cgroup-name-notfound.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Verify the environment 14 | # 15 | if [ ! -f /proc/self/cgroup ]; then 16 | snoopy_testResult_skip "File /proc/self/cgroup does not exist" 17 | fi 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | VAL_EXPECTED="(none)" 24 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup randomCgroupNameThatDefinitelyDoesntExist` 25 | 26 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 27 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cgroup-name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Verify the environment 14 | # 15 | if [ ! -f /proc/self/cgroup ]; then 16 | snoopy_testResult_skip "File /proc/self/cgroup does not exist" 17 | fi 18 | 19 | if ! grep -E ':name=systemd:' /proc/self/cgroup > /dev/null; then 20 | snoopy_testResult_skip "Cgroup :name=systemd: does not exist" 21 | fi 22 | 23 | 24 | 25 | ### Evaluate 26 | # 27 | VAL_EXPECTED=`cat /proc/self/cgroup | grep -E ':name=systemd:'` 28 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup name=systemd` 29 | 30 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 31 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cgroup-number-notfound.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Verify the environment 14 | # 15 | if [ ! -f /proc/self/cgroup ]; then 16 | snoopy_testResult_skip "File /proc/self/cgroup does not exist" 17 | fi 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | VAL_EXPECTED="(none)" 24 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup 93459234592394523419132942314` 25 | 26 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 27 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cgroup-number.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Verify the environment 14 | # 15 | if [ ! -f /proc/self/cgroup ]; then 16 | snoopy_testResult_skip "File /proc/self/cgroup does not exist" 17 | fi 18 | 19 | if ! grep -E '^1:' /proc/self/cgroup > /dev/null; then 20 | snoopy_testResult_skip "Cgroup 1: does not exist" 21 | fi 22 | 23 | 24 | 25 | ### Evaluate 26 | # 27 | VAL_EXPECTED=`cat /proc/self/cgroup | grep -E '^1:'` 28 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cgroup 1` 29 | 30 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 31 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cmdline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | COMMAND="$SNOOPY_TEST_CLI run datasource cmdline" 16 | VAL_SNOOPY=`$COMMAND` 17 | VAL_REAL="$COMMAND" 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_cwd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource cwd` 16 | VAL_REAL="$PWD" 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_datetime-fmt-epoch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | DATE_FORMAT="%s" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource datetime "$DATE_FORMAT"` 17 | snoopy_testRun_info "Snoopy value: $VAL_SNOOPY" 18 | VAL_REAL=`date "+$DATE_FORMAT"` 19 | snoopy_testRun_info "Real value: $VAL_REAL" 20 | VAL_DIFF=`expr $VAL_SNOOPY - $VAL_REAL | sed -e 's/^-//'` 21 | snoopy_testRun_info "Difference: $VAL_DIFF" 22 | 23 | 24 | 25 | ### Evaluate 26 | # 27 | # We allow 3 seconds of difference, just in case. 28 | # 29 | if [ "$VAL_DIFF" -le "3" ]; then 30 | snoopy_testResult_pass 31 | else 32 | snoopy_testResult_fail "Too much difference (diff=\"$VAL_DIFF\", snoopy=\"$VAL_SNOOPY\", real=\"$VAL_REAL\")" 33 | fi 34 | -------------------------------------------------------------------------------- /tests/datasource/datasource_datetime-fmt-static.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | DATE_FORMAT="staticStringArgumentHere" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource datetime "$DATE_FORMAT"` 17 | snoopy_testRun_info "Snoopy value: $VAL_SNOOPY" 18 | VAL_REAL=`date "+$DATE_FORMAT"` 19 | snoopy_testRun_info "Real value: $VAL_REAL" 20 | 21 | 22 | 23 | ### Evaluate 24 | # 25 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_datetime-fmt-too-long.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | DATE_FORMAT="1-------10--------20--------30--------40--------50--------60--------70---75%s" # should exceed 80 character limit and fail 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource datetime "$DATE_FORMAT"` 17 | snoopy_testRun_info "Snoopy value: $VAL_SNOOPY" 18 | VAL_REAL=`date "+$DATE_FORMAT"` 19 | snoopy_testRun_info "Real value: $VAL_REAL" 20 | 21 | 22 | 23 | ### Evaluate 24 | # 25 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_datetime-fmt-ymd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | DATE_FORMAT="%Y-%m-%d" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource datetime "$DATE_FORMAT"` 17 | snoopy_testRun_info "Snoopy value: $VAL_SNOOPY" 18 | VAL_REAL=`date "+$DATE_FORMAT"` 19 | snoopy_testRun_info "Real value: $VAL_REAL" 20 | 21 | 22 | 23 | ### Evaluate 24 | # 25 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_domain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource domain` 16 | 17 | # Getting domain is tricky on some hosts (Travis CI build boxes return empty string) 18 | # Therefore try multiple sources. 19 | VAL_REAL=`hostname -d` 20 | if [ "$VAL_REAL" == "" ]; then 21 | SNOOPY_HOSTNAME=`hostname` 22 | VAL_REAL=`cat /etc/hosts | sed -e 's/#.*//' | grep -Eo "$SNOOPY_HOSTNAME\.[-_.a-z0-9]+" | sed -e "s/$SNOOPY_HOSTNAME\.//" | head -n1` 23 | fi 24 | 25 | 26 | 27 | ### Adjust data 28 | # 29 | if [ "$VAL_REAL" == "(none)" ]; then 30 | VAL_REAL="" 31 | fi 32 | if [ "$VAL_SNOOPY" == "(none)" ]; then 33 | VAL_SNOOPY="" 34 | fi 35 | 36 | 37 | 38 | ### Evaluate 39 | # 40 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 41 | -------------------------------------------------------------------------------- /tests/datasource/datasource_egid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource egid` 16 | MY_PID=$$ 17 | VAL_REAL=`snoopy_test_getValue_fromPs "$MY_PID" "egid"` 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_egroup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource egroup` 16 | MY_PID=$$ 17 | MY_EGID=`snoopy_test_getValue_fromPs "$MY_PID" "egid"` 18 | VAL_REAL=`getent group "$MY_EGID" | cut -d: -f1` 19 | 20 | 21 | 22 | ### Evaluate 23 | # 24 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 25 | -------------------------------------------------------------------------------- /tests/datasource/datasource_env-set.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | export SNOOPY_TEST_DATASOURCE_ENV_SET="asdf" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource env "SNOOPY_TEST_DATASOURCE_ENV_SET"` 17 | VAL_REAL="$SNOOPY_TEST_DATASOURCE_ENV_SET" 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_env-unset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | unset SNOOPY_TEST_DATASOURCE_ENV_UNSET 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource env "SNOOPY_TEST_DATASOURCE_ENV_UNSET"` 17 | VAL_REAL="(undefined)" 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_env_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource env_all` 16 | 17 | 18 | 19 | ### Evaluate 20 | # 21 | if [ "$VAL_SNOOPY" != "" ]; then 22 | snoopy_testResult_pass 23 | else 24 | snoopy_testResult_fail "$VAL_SNOOPY" "" 25 | fi 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_euid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource euid` 16 | VAL_REAL="$EUID" 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_eusername.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource eusername` 16 | MY_EUID="$EUID" 17 | VAL_REAL=`getent passwd "$MY_EUID" | cut -d: -f1` 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_failure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Evaluate 14 | # 15 | if $SNOOPY_TEST_CLI run datasource failure ; then 16 | snoopy_testResult_fail "Datasource 'failure' didn't fail as expected" 17 | fi 18 | 19 | snoopy_testResult_pass 20 | -------------------------------------------------------------------------------- /tests/datasource/datasource_filename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | COMMAND_NO_ARGS="$SNOOPY_TEST_CLI" 16 | VAL_SNOOPY=`$COMMAND_NO_ARGS run datasource filename` 17 | VAL_REAL="$COMMAND_NO_ARGS" 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_gid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource gid` 16 | VAL_REAL=`id -g` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_group.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource group` 16 | VAL_REAL=`id -g -n` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_hostname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource hostname` 16 | VAL_REAL=`hostname` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_ipaddr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource ipaddr` 16 | VAL_REAL=`who -m --ips | awk '{print $5}'` || true 17 | if [[ "$VAL_REAL" == "" ]]; then 18 | VAL_REAL="-" 19 | fi 20 | 21 | 22 | 23 | ### Evaluate 24 | # 25 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_login.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource login` 16 | 17 | if ! logname 2>/dev/null; then 18 | VAL_REAL="" 19 | else 20 | VAL_REAL=`logname` 21 | fi 22 | 23 | if [ "$VAL_REAL" == "" ]; then 24 | VAL_REAL=${SUDO_USER:-} 25 | fi 26 | if [ "$VAL_REAL" == "" ]; then 27 | VAL_REAL=${LOGNAME:-} 28 | fi 29 | if [ "$VAL_REAL" == "" ]; then 30 | VAL_REAL="(unknown)" 31 | fi 32 | 33 | 34 | 35 | ### Evaluate 36 | # 37 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 38 | -------------------------------------------------------------------------------- /tests/datasource/datasource_pid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | 16 | # Run this command first, in background 17 | $SNOOPY_TEST_CLI run datasource pid > datasource_pid.out.tmp & 18 | 19 | # Capture its pid from BASH 20 | VAL_REAL=$! 21 | 22 | # Wait for it to finish 23 | wait $VAL_REAL 24 | 25 | # Get its output 26 | VAL_SNOOPY=`cat datasource_pid.out.tmp` 27 | 28 | # Do a cleanup 29 | rm -f datasource_pid.out.tmp 30 | 31 | 32 | 33 | ### Evaluate 34 | # 35 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 36 | -------------------------------------------------------------------------------- /tests/datasource/datasource_ppid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource ppid` 16 | VAL_REAL=$$ 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_rpname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource rpname` 16 | 17 | # Get root process PID 18 | CUR_PID=$$ 19 | NEW_PPID=`snoopy_test_getValue_fromPs "$CUR_PID" "ppid"` 20 | I=0 21 | # Stop at: 22 | # - PID 1: init 23 | # - PID 0: appears in container when attached to it from the host 24 | while [[ "$NEW_PPID" != "1" ]] && [[ "$NEW_PPID" != "0" ]]; do 25 | I=`expr $I + 1` 26 | if [ "$I" -gt "100" ]; then 27 | snoopy_testResult_fail "Endless loop". 28 | fi 29 | 30 | CUR_PID="$NEW_PPID" 31 | NEW_PPID=`snoopy_test_getValue_fromPs "$NEW_PPID" "ppid"` 32 | done 33 | 34 | # Get root parent process name 35 | VAL_REAL=`cat /proc/$CUR_PID/status | grep '^Name:' | sed 's/^Name:\t//'` 36 | 37 | 38 | 39 | ### Evaluate 40 | # 41 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 42 | -------------------------------------------------------------------------------- /tests/datasource/datasource_sid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource sid` 16 | MY_PID=$$ 17 | VAL_REAL=`snoopy_test_getValue_fromPs "$MY_PID" "sid"` 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/datasource/datasource_snoopy_configure_command.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource snoopy_configure_command` 16 | 17 | 18 | 19 | ### Evaluate 20 | # 21 | if [[ $VAL_SNOOPY =~ \./configure ]]; then 22 | snoopy_testResult_pass 23 | else 24 | snoopy_testResult_fail "The output does not start with './configure'. Instead, we got this: $VAL_SNOOPY" 25 | fi 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_snoopy_literal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="test-string-`date +%s`" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource snoopy_literal "$VAL_REAL"` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_snoopy_threads.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="1" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource snoopy_threads ""` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_tid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource tid` 16 | 17 | 18 | 19 | ### Evaluate 20 | # 21 | if [[ $VAL_SNOOPY =~ ^[0-9]{10,16}$ ]]; then 22 | snoopy_testResult_pass 23 | else 24 | snoopy_testResult_fail "Unexpected thread ID format: $VAL_SNOOPY" 25 | fi 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_tid_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource tid_kernel` 16 | 17 | 18 | 19 | ### Evaluate 20 | # 21 | if [[ $VAL_SNOOPY =~ ^[0-9]{1,7}$ ]]; then 22 | snoopy_testResult_pass 23 | else 24 | snoopy_testResult_fail "Unexpected thread ID format: $VAL_SNOOPY" 25 | fi 26 | -------------------------------------------------------------------------------- /tests/datasource/datasource_timestamp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource timestamp` 16 | snoopy_testRun_info "Snoopy value: $VAL_SNOOPY" 17 | VAL_REAL=`date +"%s"` 18 | snoopy_testRun_info "Real value: $VAL_REAL" 19 | VAL_DIFF=`expr $VAL_SNOOPY - $VAL_REAL | sed -e 's/^-//'` 20 | snoopy_testRun_info "Difference: $VAL_DIFF" 21 | 22 | 23 | 24 | ### Evaluate 25 | # 26 | # We allow 3 seconds of difference, just in case. 27 | # 28 | if [ "$VAL_DIFF" -le "3" ]; then 29 | snoopy_testResult_pass 30 | else 31 | snoopy_testResult_fail "Too much difference (diff=\"$VAL_DIFF\", snoopy=\"$VAL_SNOOPY\", real=\"$VAL_REAL\")" 32 | fi 33 | -------------------------------------------------------------------------------- /tests/datasource/datasource_timestamp_ms.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY_1=`$SNOOPY_TEST_CLI run datasource timestamp_ms` 16 | sleep 0.005 17 | VAL_SNOOPY_2=`$SNOOPY_TEST_CLI run datasource timestamp_ms` 18 | if [ "$VAL_SNOOPY_1" -gt "$VAL_SNOOPY_2" ]; then 19 | VAL_SNOOPY_1=`$SNOOPY_TEST_CLI run datasource timestamp_ms` 20 | sleep 0.005 21 | VAL_SNOOPY_2=`$SNOOPY_TEST_CLI run datasource timestamp_ms` 22 | fi 23 | 24 | 25 | 26 | ### Evaluate 27 | # 28 | VAL_DIFF=`expr $VAL_SNOOPY_2 - $VAL_SNOOPY_1` 29 | if [[ "$VAL_DIFF" -ge "5" ]] && [[ "$VAL_DIFF" -lt "500" ]]; then 30 | snoopy_testResult_pass "$VAL_DIFF" 31 | else 32 | snoopy_testResult_fail "${VAL_SNOOPY_1}ms ${VAL_SNOOPY_2}ms" 33 | fi 34 | -------------------------------------------------------------------------------- /tests/datasource/datasource_timestamp_us.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY_1=`$SNOOPY_TEST_CLI run datasource timestamp_us` 16 | sleep 0.005 17 | VAL_SNOOPY_2=`$SNOOPY_TEST_CLI run datasource timestamp_us` 18 | if [ "$VAL_SNOOPY_1" -gt "$VAL_SNOOPY_2" ]; then 19 | VAL_SNOOPY_1=`$SNOOPY_TEST_CLI run datasource timestamp_us` 20 | sleep 0.005 21 | VAL_SNOOPY_2=`$SNOOPY_TEST_CLI run datasource timestamp_us` 22 | fi 23 | 24 | 25 | 26 | ### Evaluate 27 | # 28 | VAL_DIFF=`expr $VAL_SNOOPY_2 - $VAL_SNOOPY_1` 29 | if [[ "$VAL_DIFF" -ge "5000" ]] && [[ "$VAL_DIFF" -lt "50000" ]]; then 30 | snoopy_testResult_pass "$VAL_DIFF" 31 | else 32 | snoopy_testResult_fail "${VAL_SNOOPY_1}ms ${VAL_SNOOPY_2}ms" 33 | fi 34 | -------------------------------------------------------------------------------- /tests/datasource/datasource_tty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource tty` 16 | if [ "(unknown)" == "$VAL_SNOOPY" ]; then 17 | VAL_SNOOPY="(none)" 18 | fi 19 | 20 | if ! tty -s; then 21 | VAL_REAL="(none)" 22 | else 23 | VAL_REAL=`tty` 24 | if [ "not a tty" == "$VAL_REAL" ]; then 25 | VAL_REAL="(none)" 26 | fi 27 | fi 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 34 | -------------------------------------------------------------------------------- /tests/datasource/datasource_tty_uid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource tty_uid` 16 | if [ "(unknown)" == "$VAL_SNOOPY" ]; then 17 | VAL_SNOOPY="(none)" 18 | fi 19 | 20 | if ! tty -s; then 21 | VAL_REAL="(none)" 22 | else 23 | VAL_REAL=`tty` 24 | if [ "not a tty" == "$VAL_REAL" ]; then 25 | VAL_REAL="(none)" 26 | else 27 | VAL_REAL=`echo "$VAL_REAL" | xargs ls -lan | awk '{print $3}'` 28 | fi 29 | fi 30 | 31 | 32 | 33 | ### Evaluate 34 | # 35 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 36 | -------------------------------------------------------------------------------- /tests/datasource/datasource_tty_username.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource tty_username` 16 | if [ "(unknown)" == "$VAL_SNOOPY" ]; then 17 | VAL_SNOOPY="(none)" 18 | fi 19 | 20 | if ! tty -s; then 21 | VAL_REAL="(none)" 22 | else 23 | TTY_PATH=`tty` 24 | if [ "not a tty" == "$TTY_PATH" ]; then 25 | VAL_REAL="(none)" 26 | else 27 | VAL_REAL=`stat -c %U $TTY_PATH` 28 | fi 29 | fi 30 | 31 | 32 | 33 | ### Evaluate 34 | # 35 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 36 | -------------------------------------------------------------------------------- /tests/datasource/datasource_uid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource uid` 16 | VAL_REAL=`id -u` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/datasource/datasource_username.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run datasource username` 16 | VAL_REAL=`id -u -n` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/filter/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustdrop-multiarg-first.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Shell workaround 14 | # 15 | # CI usually runs commands in a way similar to `docker exec ...`, and certain 16 | # distro containers report shell in a process table as `sh` and not as `bash`. 17 | # 18 | PARENT_PROC_NAME="bash" 19 | . /etc/os-release 20 | if [[ $ID =~ ^(alpine|arch|almalinux|centos|fedora|rhel|opensuse) ]]; then 21 | PARENT_PROC_NAME="sh" 22 | fi 23 | 24 | 25 | 26 | ### Get data 27 | # 28 | if ! $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "$PARENT_PROC_NAME,aaaa,bbbb" > /dev/null; then 29 | snoopy_testResult_pass 30 | else 31 | snoopy_testResult_fail "Message passed through when it shouldn't." 32 | fi 33 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustdrop-multiarg-last.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Shell workaround 14 | # 15 | # CI usually runs commands in a way similar to `docker exec ...`, and certain 16 | # distro containers report shell in a process table as `sh` and not as `bash`. 17 | # 18 | PARENT_PROC_NAME="bash" 19 | . /etc/os-release 20 | if [[ $ID =~ ^(alpine|arch|almalinux|centos|fedora|rhel|opensuse) ]]; then 21 | PARENT_PROC_NAME="sh" 22 | fi 23 | 24 | 25 | 26 | ### Get data 27 | # 28 | if ! $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "aaaa,bbbb,$PARENT_PROC_NAME" > /dev/null; then 29 | snoopy_testResult_pass 30 | else 31 | snoopy_testResult_fail "Message passed through when it shouldn't." 32 | fi 33 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustdrop-multiarg-mid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Shell workaround 14 | # 15 | # CI usually runs commands in a way similar to `docker exec ...`, and certain 16 | # distro containers report shell in a process table as `sh` and not as `bash`. 17 | # 18 | PARENT_PROC_NAME="bash" 19 | . /etc/os-release 20 | if [[ $ID =~ ^(alpine|arch|almalinux|centos|fedora|rhel|opensuse) ]]; then 21 | PARENT_PROC_NAME="sh" 22 | fi 23 | 24 | 25 | 26 | ### Get data 27 | # 28 | if ! $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "aaaa,$PARENT_PROC_NAME,bbbb" > /dev/null; then 29 | snoopy_testResult_pass 30 | else 31 | snoopy_testResult_fail "Message passed through when it shouldn't." 32 | fi 33 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustdrop-singlearg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Shell workaround 14 | # 15 | # CI usually runs commands in a way similar to `docker exec ...`, and certain 16 | # distro containers report shell in a process table as `sh` and not as `bash`. 17 | # 18 | PARENT_PROC_NAME="bash" 19 | . /etc/os-release 20 | if [[ $ID =~ ^(alpine|arch|almalinux|centos|fedora|rhel|opensuse) ]]; then 21 | PARENT_PROC_NAME="sh" 22 | fi 23 | 24 | 25 | 26 | ### Get data 27 | # 28 | if ! $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "$PARENT_PROC_NAME" > /dev/null; then 29 | snoopy_testResult_pass 30 | else 31 | snoopy_testResult_fail "Message passed through when it shouldn't." 32 | fi 33 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustdrop-spaceparent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | if ! "$SNOOPY_TESTS_BINDIR/space parent" $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "space parent"; then 16 | snoopy_testResult_pass 17 | else 18 | snoopy_testResult_fail "Message passed through when it shouldn't." 19 | fi 20 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustlog-multiarg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | if $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "aaaa,bbbb,cccc" > /dev/null; then 16 | snoopy_testResult_pass 17 | else 18 | snoopy_testResult_fail "Message unexpectedly dropped." 19 | fi 20 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustlog-singlearg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | if $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "aaaa" > /dev/null; then 16 | snoopy_testResult_pass 17 | else 18 | snoopy_testResult_fail "Message unexpectedly dropped." 19 | fi 20 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_spawns_of-mustlog-spaceparent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | if "$SNOOPY_TESTS_BINDIR/space parent" $SNOOPY_TEST_CLI run filter "exclude_spawns_of" "parachuteparent"; then 16 | snoopy_testResult_pass 17 | else 18 | snoopy_testResult_fail "Message passed through when it shouldn't." 19 | fi 20 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_uid-drop-multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | MY_UID_PLUS_2=`expr $MY_UID + 2` 18 | if ! $SNOOPY_TEST_CLI run filter "exclude_uid" "$MY_UID_PLUS_1,$MY_UID,$MY_UID_PLUS_2" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_uid-drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | if ! $SNOOPY_TEST_CLI run filter "exclude_uid" "$MY_UID" > /dev/null; then 17 | snoopy_testResult_pass 18 | else 19 | snoopy_testResult_fail "My UID: $MY_UID" 20 | fi 21 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_uid-pass-multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | MY_UID_PLUS_2=`expr $MY_UID + 2` 18 | MY_UID_PLUS_3=`expr $MY_UID + 3` 19 | if ! $SNOOPY_TEST_CLI run filter "exclude_uid" "$MY_UID_PLUS_1,$MY_UID_PLUS_2,$MY_UID_PLUS_3" > /dev/null; then 20 | snoopy_testResult_fail "My UID: $MY_UID" 21 | else 22 | snoopy_testResult_pass 23 | fi 24 | -------------------------------------------------------------------------------- /tests/filter/filter_exclude_uid-pass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | if ! $SNOOPY_TEST_CLI run filter "exclude_uid" "$MY_UID_PLUS_1" > /dev/null; then 18 | snoopy_testResult_fail "My UID: $MY_UID" 19 | else 20 | snoopy_testResult_pass 21 | fi 22 | -------------------------------------------------------------------------------- /tests/filter/filter_only_uid-drop-multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | MY_UID_PLUS_2=`expr $MY_UID + 2` 18 | MY_UID_PLUS_3=`expr $MY_UID + 3` 19 | if ! $SNOOPY_TEST_CLI run filter "only_uid" "$MY_UID_PLUS_1,$MY_UID_PLUS_2,$MY_UID_PLUS_3" > /dev/null; then 20 | snoopy_testResult_pass 21 | else 22 | snoopy_testResult_fail "My UID: $MY_UID" 23 | fi 24 | -------------------------------------------------------------------------------- /tests/filter/filter_only_uid-drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | 18 | if ! $SNOOPY_TEST_CLI run filter "only_uid" "$MY_UID_PLUS_1" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filter_only_uid-pass-multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | MY_UID_PLUS_2=`expr $MY_UID + 2` 18 | if ! $SNOOPY_TEST_CLI run filter "only_uid" "$MY_UID_PLUS_1,$MY_UID,$MY_UID_PLUS_2" > /dev/null; then 19 | snoopy_testResult_fail "My UID: $MY_UID" 20 | else 21 | snoopy_testResult_pass 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filter_only_uid-pass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | if ! $SNOOPY_TEST_CLI run filter "only_uid" "$MY_UID" > /dev/null; then 17 | snoopy_testResult_fail "My UID: $MY_UID" 18 | else 19 | snoopy_testResult_pass 20 | fi 21 | -------------------------------------------------------------------------------- /tests/filter/filterchain-double-bothdrop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | 18 | if ! $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID_PLUS_1;only_uid:$MY_UID_PLUS_1" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filterchain-double-bothpass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | 17 | if $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID;only_uid:$MY_UID" > /dev/null; then 18 | snoopy_testResult_pass 19 | else 20 | snoopy_testResult_fail "My UID: $MY_UID" 21 | fi 22 | -------------------------------------------------------------------------------- /tests/filter/filterchain-double-firstdrops.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | 18 | if ! $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID_PLUS_1;only_uid:$MY_UID" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filterchain-double-seconddrops.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | 18 | if ! $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID;only_uid:$MY_UID_PLUS_1" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filterchain-single-drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | 18 | if ! $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID_PLUS_1" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filterchain-single-pass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | if ! $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID" > /dev/null; then 17 | snoopy_testResult_fail "My UID: $MY_UID" 18 | else 19 | snoopy_testResult_pass 20 | fi 21 | -------------------------------------------------------------------------------- /tests/filter/filterchain-trailing-semicolon-drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | MY_UID_PLUS_1=`expr $MY_UID + 1` 17 | 18 | if ! $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID_PLUS_1;" > /dev/null; then 19 | snoopy_testResult_pass 20 | else 21 | snoopy_testResult_fail "My UID: $MY_UID" 22 | fi 23 | -------------------------------------------------------------------------------- /tests/filter/filterchain-trailing-semicolon-pass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | MY_UID=`$SNOOPY_TEST_CLI run datasource uid` 16 | 17 | if $SNOOPY_TEST_CLI run filterchain "only_uid:$MY_UID;" > /dev/null; then 18 | snoopy_testResult_pass 19 | else 20 | snoopy_testResult_fail "My UID: $MY_UID" 21 | fi 22 | -------------------------------------------------------------------------------- /tests/filter/filterchain-unknown-filter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Search for failures 14 | # 15 | ORIG_MESSAGE="msg" 16 | FILTER_CHAIN="someUnknownFilter:someBogusArgument" 17 | 18 | if ! $SNOOPY_TEST_CLI run filterchain "$FILTER_CHAIN" > /dev/null; then 19 | snoopy_testResult_fail "Filter unexpectedly dropped the message" 20 | fi 21 | 22 | ADJ_MESSAGE=`$SNOOPY_TEST_CLI run filterchain "$FILTER_CHAIN" | grep -E '^ *Adjusted message: ' | sed -e 's/^ *Adjusted message: //'` 23 | if [[ "$ORIG_MESSAGE" == "$ADJ_MESSAGE" ]]; then 24 | snoopy_testResult_fail "Filter chain processor didn't adjust the message to report an unknown filter" 25 | fi 26 | 27 | 28 | 29 | ### Success 30 | # 31 | snoopy_testResult_pass 32 | -------------------------------------------------------------------------------- /tests/general/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Which tests to run 8 | # 9 | TESTS = 10 | XFAIL_TESTS = 11 | 12 | TESTS += general-symbol-leaks.sh 13 | 14 | 15 | 16 | ### Include tests in distribution archive 17 | # 18 | EXTRA_DIST = _bootstrap.sh 19 | EXTRA_DIST += $(TESTS) 20 | 21 | 22 | 23 | ### Remove stale temporary test files, if tests got stuck 24 | # 25 | clean-local-this-dir: 26 | rm -f *.ini ; 27 | rm -f *.out ; 28 | -------------------------------------------------------------------------------- /tests/general/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/general/general-symbol-leaks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Check for leaked global symbols 14 | # 15 | RES=`nm $SNOOPY_LIBSNOOPY_TEST_SO_PATH | grep ' T ' | grep -v ' snoopy_' | grep -Ev ' (execve?|_init|_fini|__gcov_sort_n_vals|mangle_path)$' | grep -c . | cat` 16 | if [ "$RES" != "0" ]; then 17 | nm $SNOOPY_LIBSNOOPY_TEST_SO_PATH | grep ' T ' | grep -v ' snoopy_' | grep -Ev ' (execve?|_init|_fini)$' | cat 18 | snoopy_testResult_fail "The .so library is leaking global symbols that are not prefixed with 'snoopy_' prefix or declared as 'static'. Inspect with 'nm $SNOOPY_LIBSNOOPY_TEST_SO_PATH' manually." 19 | else 20 | snoopy_testResult_pass "No leaked symbols found." 21 | fi 22 | -------------------------------------------------------------------------------- /tests/message/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Which tests to run 8 | # 9 | TESTS = 10 | XFAIL_TESTS = 11 | 12 | TESTS += message_format-datasource-arg.sh 13 | TESTS += message_format-datasource-noarg.sh 14 | TESTS += message_format-ds-closing-tag-missing.sh 15 | TESTS += message_format-ds-unknown.sh 16 | TESTS += message_format-ds-failure.sh 17 | TESTS += message_format-empty.sh 18 | TESTS += message_format-static.sh 19 | 20 | 21 | 22 | ### Include tests in distribution archive 23 | # 24 | EXTRA_DIST = _bootstrap.sh 25 | EXTRA_DIST += $(TESTS) 26 | -------------------------------------------------------------------------------- /tests/message/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/message/message_format-datasource-arg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Check if there is ENV datasource available 14 | # 15 | RES=`$SNOOPY_TEST_CLI run datasource --list | grep -E '^ *(snoopy_version|env)$' -c` 16 | if [ "$RES" -eq "1" ]; then 17 | snoopy_testResult_skip "Required datasource 'env' is not available" 18 | fi 19 | 20 | 21 | 22 | ### Get data 23 | # 24 | VAR_NAME="SNOOPY_TEST_MESSAGE_FORMAT_`date +%s`" 25 | VAR_VALUE="${VAR_NAME}-value" 26 | export $VAR_NAME="$VAR_VALUE" 27 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "%{env:$VAR_NAME}"` 28 | VAL_REAL="$VAR_VALUE" 29 | 30 | 31 | 32 | ### Evaluate 33 | # 34 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 35 | -------------------------------------------------------------------------------- /tests/message/message_format-datasource-noarg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | DATASOURCE="snoopy_version" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "%{$DATASOURCE}"` 17 | VAL_REAL=`$SNOOPY_TEST_CLI run datasource "$DATASOURCE"` 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/message/message_format-ds-closing-tag-missing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="[ERROR: Closing data source tag ('}') not found.]" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "%{failure"` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/message/message_format-ds-failure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="[ERROR: Data source 'failure' failed with the following error message: 'Artificial datasource failure triggered']" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "%{failure}"` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/message/message_format-ds-unknown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="[ERROR: Data source 'dataSourceThatDoesNotExist' not found.]" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "%{dataSourceThatDoesNotExist}"` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/message/message_format-empty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | STR="" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "$STR"` 17 | VAL_REAL="$STR" 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/message/message_format-static.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | STR="staticUselessText-`date +%s`" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run messageformat "$STR"` 17 | VAL_REAL="$STR" 18 | 19 | 20 | 21 | ### Evaluate 22 | # 23 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 24 | -------------------------------------------------------------------------------- /tests/output/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Which tests to run 8 | # 9 | TESTS = 10 | XFAIL_TESTS = 11 | 12 | if OUTPUT_ENABLED_devnull 13 | TESTS += output_devnull.sh 14 | endif 15 | 16 | if OUTPUT_ENABLED_file 17 | TESTS += output_file.sh 18 | if DATASOURCE_ENABLED_username 19 | TESTS += output_file-dynamic.sh 20 | endif 21 | if DATASOURCE_ENABLED_snoopy_literal 22 | TESTS += output_file-dynamic-arg.sh 23 | endif 24 | endif 25 | 26 | TESTS += output_noop.sh 27 | 28 | if OUTPUT_ENABLED_socket 29 | TESTS += output_socket.sh 30 | endif 31 | 32 | if OUTPUT_ENABLED_stderr 33 | TESTS += output_stderr.sh 34 | endif 35 | 36 | if OUTPUT_ENABLED_stdout 37 | TESTS += output_stdout.sh 38 | endif 39 | 40 | 41 | 42 | ### Include tests in distribution archive 43 | # 44 | EXTRA_DIST = _bootstrap.sh 45 | EXTRA_DIST += $(TESTS) 46 | -------------------------------------------------------------------------------- /tests/output/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/output/output_devnull.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL="" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run output "$VAL_REAL" "devnull"` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/output/output_file-dynamic-arg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL=`date +%s` 16 | MY_PID=$$ 17 | MY_USERNAME=`whoami` 18 | FILE_EXPECTED="output_file-dynamic-arg.sh.$MY_PID-asdf.tmp.out" 19 | FILE_FORMAT="output_file-dynamic-arg.sh.$MY_PID-%{snoopy_literal:asdf}.tmp.out" 20 | 21 | # Write 22 | rm -f $FILE_EXPECTED 23 | $SNOOPY_TEST_CLI run output "$VAL_REAL" "file" "$FILE_FORMAT" > /dev/null 24 | 25 | # Read 26 | VAL_SNOOPY=`cat $FILE_EXPECTED` 27 | rm -f $FILE_EXPECTED 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 34 | -------------------------------------------------------------------------------- /tests/output/output_file-dynamic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL=`date +%s` 16 | MY_PID=$$ 17 | MY_USERNAME=`whoami` 18 | FILE_EXPECTED="output_file-dynamic.sh.$MY_PID-$MY_USERNAME.tmp.out" 19 | FILE_FORMAT="output_file-dynamic.sh.$MY_PID-%{username}.tmp.out" 20 | 21 | # Write 22 | rm -f $FILE_EXPECTED 23 | $SNOOPY_TEST_CLI run output "$VAL_REAL" "file" "$FILE_FORMAT" > /dev/null 24 | 25 | # Read 26 | VAL_SNOOPY=`cat $FILE_EXPECTED` 27 | rm -f $FILE_EXPECTED 28 | 29 | 30 | 31 | ### Evaluate 32 | # 33 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 34 | -------------------------------------------------------------------------------- /tests/output/output_file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL=`date +%s` 16 | MY_PID=$$ 17 | FILE="output_file.sh.$MY_PID.tmp.out" 18 | 19 | # Write 20 | rm -f $FILE 21 | $SNOOPY_TEST_CLI run output "$VAL_REAL" "file" "$FILE" > /dev/null 22 | 23 | # Read 24 | VAL_SNOOPY=`cat $FILE` 25 | rm -f $FILE 26 | 27 | 28 | 29 | ### Evaluate 30 | # 31 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 32 | -------------------------------------------------------------------------------- /tests/output/output_noop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL="" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run output "$VAL_REAL" "noop"` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/output/output_stderr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL=`date +%s` 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run output "$VAL_REAL" "stderr" 2>&1 >/dev/null` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/output/output_stdout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Output data 14 | # 15 | VAL_REAL=`date +%s` 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI run output "$VAL_REAL" "stdout" 2>/dev/null` 17 | 18 | 19 | 20 | ### Evaluate 21 | # 22 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 23 | -------------------------------------------------------------------------------- /tests/threads/Makefile.am: -------------------------------------------------------------------------------- 1 | ### Include common Makefile configuration 2 | # 3 | include $(top_srcdir)/build/Makefile.am.common 4 | 5 | 6 | 7 | ### Which tests to run 8 | # 9 | TESTS = 10 | XFAIL_TESTS = 11 | 12 | if THREAD_SAFETY_ENABLED 13 | TESTS += threads_creation.sh 14 | TESTS += threads_fork_exec.sh 15 | TESTS += threads_try-to-segfault.sh 16 | endif 17 | 18 | 19 | 20 | ### Include tests in distribution archive 21 | # 22 | EXTRA_DIST = _bootstrap.sh 23 | EXTRA_DIST += $(TESTS) 24 | -------------------------------------------------------------------------------- /tests/threads/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/threads/threads_creation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="100" 16 | #$SNOOPY_TEST_THREADS $VAL_REAL 17 | #VAL_SNOOPY=`$SNOOPY_TEST_THREADS $VAL_REAL| grep '^SUCCESS' | grep -Eo '[0-9]+$'` 18 | $SNOOPY_TEST_CLI stress threads $VAL_REAL 19 | 20 | 21 | 22 | ### Evaluate 23 | # 24 | #snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 25 | -------------------------------------------------------------------------------- /tests/threads/threads_fork_exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | #set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Get data 14 | # 15 | VAL_REAL="1" 16 | THREAD_COUNT="100" 17 | THREAD_EXEC_CMD="/bin/hostname" 18 | VAL_SNOOPY=`$SNOOPY_TEST_CLI stress threadsexec $THREAD_COUNT $THREAD_EXEC_CMD | grep '^SUCCESS' -c | cat` 19 | 20 | 21 | 22 | ### Evaluate 23 | # 24 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL" 25 | -------------------------------------------------------------------------------- /tests/threads/threads_try-to-segfault.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Default config 14 | # 15 | ITERATIONS="100" 16 | THREAD_COUNT="200" 17 | 18 | 19 | 20 | ### Override with CLI args 21 | # 22 | if [ ! -z ${1:-} ]; then 23 | ITERATIONS="$1" 24 | fi 25 | if [ ! -z ${2:-} ]; then 26 | THREAD_COUNT="$2" 27 | fi 28 | 29 | 30 | 31 | ### Run the test 32 | # 33 | echo "Running $ITERATIONS iterations with $THREAD_COUNT threads in each:" 34 | for i in `seq 1 $ITERATIONS`; do 35 | echo -n " Iteration #$i... " 36 | $SNOOPY_TEST_CLI stress threads $THREAD_COUNT > /dev/null 37 | RES=$? 38 | if [ "$RES" == "0" ]; then 39 | echo "done, exit status = $?" 40 | else 41 | echo 42 | echo " ERROR: Exit status = $?" 43 | fi 44 | done 45 | 46 | 47 | 48 | ### Evaluate 49 | # 50 | snoopy_testResult_pass "No segmentation faults occured. Iterations: $ITERATIONS. Threads-per-iteration: $THREAD_COUNT." 51 | -------------------------------------------------------------------------------- /tests/unit/_bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell 6 | # 7 | set -e 8 | set -u 9 | 10 | 11 | 12 | ### Include main _bootstrap.sh 13 | # 14 | . `dirname $BASH_SOURCE`/../_bootstrap.sh 15 | -------------------------------------------------------------------------------- /tests/unit/unit-action-log-message-dispatch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | VAL_EXPECTED="Test error message, sent out via stdout output." 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI unit action log-message-dispatch | head -n1` 17 | 18 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 19 | -------------------------------------------------------------------------------- /tests/unit/unit-action-log-syscall-exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | VAL_EXPECTED="Test error message, sent out via stdout output." 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI unit action log-syscall-exec | head -n1` 17 | 18 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 19 | -------------------------------------------------------------------------------- /tests/unit/unit-datasource-cmdline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit datasource cmdline 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-error.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit error 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-ext-ini.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit ext-ini 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-filterregistry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit filterregistry 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-outputregistry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit outputregistry 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-util-parser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit util parser 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-util-syslog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit util syslog 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-util-systemd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | $SNOOPY_TEST_CLI unit util systemd 16 | 17 | 18 | 19 | ### Success 20 | # 21 | snoopy_testResult_pass 22 | -------------------------------------------------------------------------------- /tests/unit/unit-util-utmp-entry-missing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | VAL_EXPECTED="(Entry not found.)" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI unit util utmp /dev/pts/9 $SNOOPY_CUR_TEST_DIR/unit-util-utmp-testUtmpFile` 17 | 18 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 19 | -------------------------------------------------------------------------------- /tests/unit/unit-util-utmp-entry-without-ip-address.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | VAL_EXPECTED="-" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI unit util utmp /dev/tty1 $SNOOPY_CUR_TEST_DIR/unit-util-utmp-testUtmpFile` 17 | 18 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 19 | -------------------------------------------------------------------------------- /tests/unit/unit-util-utmp-ipv4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | VAL_EXPECTED="89.16.143.91" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI unit util utmp /dev/pts/1 $SNOOPY_CUR_TEST_DIR/unit-util-utmp-testUtmpFile` 17 | 18 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 19 | -------------------------------------------------------------------------------- /tests/unit/unit-util-utmp-ipv6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ### Configure shell and bootstrap 6 | # 7 | set -e 8 | set -u 9 | . `dirname $BASH_SOURCE`/_bootstrap.sh 10 | 11 | 12 | 13 | ### Run the mock test 14 | # 15 | VAL_EXPECTED="2a01:4f8:c17:785c::1" 16 | VAL_SNOOPY=`$SNOOPY_TEST_CLI unit util utmp /dev/pts/2 $SNOOPY_CUR_TEST_DIR/unit-util-utmp-testUtmpFile` 17 | 18 | snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_EXPECTED" 19 | -------------------------------------------------------------------------------- /tests/unit/unit-util-utmp-testUtmpFile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a2o/snoopy/338a8d1c9cc15db36895d510939da7527f32f4f6/tests/unit/unit-util-utmp-testUtmpFile --------------------------------------------------------------------------------