Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output/file: Fix datasource argument handling in output specification #274

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ int snoopy_configfile_parseValue_output (
outputArg = "";
} else {
// Separate output name from its arguments
// (arguments may contain further ':' characters, like "file:/var/log/snoopy-%{datetime:%Y-%m-%d}")
outputName = strtok_r(confVal, ":", &saveptr1);
outputArg = strtok_r(NULL , ":", &saveptr1);
outputArg = outputName + strlen(outputName) + 1;
outputArgFound = SNOOPY_TRUE;

}

// Determine output name
Expand Down
3 changes: 3 additions & 0 deletions tests/output/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ if OUTPUT_ENABLED_file
if DATASOURCE_ENABLED_username
TESTS += output_file-dynamic.sh
endif
if DATASOURCE_ENABLED_snoopy_literal
TESTS += output_file-dynamic-arg.sh
endif
endif

TESTS += output_noop.sh
Expand Down
33 changes: 33 additions & 0 deletions tests/output/output_file-dynamic-arg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash



### Configure shell and bootstrap
#
set -e
set -u
. `dirname $BASH_SOURCE`/_bootstrap.sh



### Output data
#
VAL_REAL=`date +%s`
MY_PID=$$
MY_USERNAME=`whoami`
FILE_EXPECTED="output_file-dynamic-arg.sh.$MY_PID-asdf.tmp.out"
FILE_FORMAT="output_file-dynamic-arg.sh.$MY_PID-%{snoopy_literal:asdf}.tmp.out"

# Write
rm -f $FILE_EXPECTED
$SNOOPY_TEST_CLI run output "$VAL_REAL" "file" "$FILE_FORMAT" > /dev/null

# Read
VAL_SNOOPY=`cat $FILE_EXPECTED`
rm -f $FILE_EXPECTED



### Evaluate
#
snoopy_test_compareValues "$VAL_SNOOPY" "$VAL_REAL"
Loading