Now logging defaults to stderr.

pull/156/head
Fredrik Öhrström 2020-09-13 16:55:22 +02:00
rodzic 71804f1d92
commit 802e62cbbd
22 zmienionych plików z 127 dodań i 63 usunięć

Wyświetl plik

@ -166,7 +166,8 @@ As <options> you can use:
--separator=<c> change field separator to c
--shell=<cmdline> invokes cmdline with env variables containing the latest reading
--useconfig=<dir> load config files from dir/etc
--usestderr write debug/verbose and logging output to stderr
--usestderr write notices/debug/verbose and other logging output to stderr (the default)
--usestdoutforlogging write debug/verbose and logging output to stdout
--verbose for more information
As <device> you can use:

Wyświetl plik

@ -351,8 +351,13 @@ unique_ptr<Configuration> parseCommandLine(int argc, char **argv) {
i++;
continue;
}
if (!strncmp(argv[i], "--usestderr=", 10)) {
c->use_stderr = true;
if (!strncmp(argv[i], "--usestderr", 11)) {
c->use_stderr_for_log = true;
i++;
continue;
}
if (!strncmp(argv[i], "--usestdoutforlogging", 13)) {
c->use_stderr_for_log = false;
i++;
continue;
}

Wyświetl plik

@ -65,7 +65,7 @@ struct Configuration
MeterFileNaming meterfiles_naming {};
MeterFileTimestamp meterfiles_timestamp {}; // Default is never.
bool use_logfile {};
bool use_stderr {};
bool use_stderr_for_log = true; // Default is to use stderr for logging.
std::string logfile;
bool json {};
bool fields {};

Wyświetl plik

@ -77,6 +77,10 @@ set<string> not_serial_wmbus_devices_;
// but they might not be available for wmbusmeters.
set<string> not_swradio_wmbus_devices_;
// When manually supplying stdin or a file, then, after
// it has been read, do not open it again!
set<string> do_not_open_file_again_;
// Rendering the telegrams to json,fields or shell calls is
// done by the printer.
unique_ptr<Printer> printer_;
@ -338,7 +342,8 @@ void list_shell_envs(Configuration *config, string meter_type)
&config->jsons,
&config->selected_fields);
for (auto &e : envs) {
for (auto &e : envs)
{
int p = e.find('=');
string key = e.substr(0,p);
printf("%s\n", key.c_str());
@ -498,6 +503,10 @@ void check_for_dead_wmbus_devices(Configuration *config)
if (!w->isWorking())
{
not_working.push_back(w.get());
if (!config->use_auto_detect)
{
notice("Lost %s closing %s\n", w->device().c_str(), toString(w->type()));
}
}
}
@ -535,8 +544,14 @@ void check_for_dead_wmbus_devices(Configuration *config)
void open_wmbus_device(Configuration *config, string how, string device, Detected *detected)
{
// A newly plugged in device has been manually configured or automatically detected! Start using it!
info("(main) %s %s on %s\n", how.c_str(), toString(detected->type), device.c_str());
if (config->use_auto_detect)
{
notice("Detected %s %s on %s\n", how.c_str(), toString(detected->type), device.c_str());
}
else
{
verbose("(main) %s %s on %s\n", how.c_str(), toString(detected->type), device.c_str());
}
LOCK("(main)", "perform_auto_scan_of_devices", devices_lock_);
unique_ptr<WMBus> w = createWMBusDeviceFrom(detected, config, serial_manager_.get());
wmbus_devices_.push_back(std::move(w));
@ -571,7 +586,7 @@ void perform_auto_scan_of_serial_devices(Configuration *config)
{
debug("(main) device %s not currently used, detect contents...\n", device.c_str());
// This serial device is not in use.
Detected detected = detectImstAmberCul(device, "", "", serial_manager_.get());
Detected detected = detectImstAmberCul(device, "", "", serial_manager_.get(), true, false, false);
if (detected.type == DEVICE_UNKNOWN)
{
// This serial device was something that we could not recognize.
@ -645,14 +660,26 @@ void detectAndConfigureWMBusDevices(Configuration *config)
continue;
}
Detected detected = detectWMBusDeviceSetting(device.file,
device.suffix,
device.linkmodes,
serial_manager_.get());
if (detected.type != DEVICE_UNKNOWN)
if (do_not_open_file_again_.count(device.file) == 0)
{
open_wmbus_device(config, "manual configuration", device.str(), &detected);
Detected detected = detectWMBusDeviceSetting(device.file,
device.suffix,
device.linkmodes,
serial_manager_.get());
if (detected.type != DEVICE_UNKNOWN)
{
if (detected.is_stdin || detected.is_file)
{
// Only read stdin and files once!
do_not_open_file_again_.insert(device.file);
}
open_wmbus_device(config, "manual configuration", device.str(), &detected);
}
}
else
{
trace("(MAIN) ignoring handled file %s\n", device.file.c_str());
}
}
@ -708,7 +735,7 @@ bool start(Configuration *config)
debugEnabled(config->debug);
internalTestingEnabled(config->internaltesting);
traceEnabled(config->trace);
stderrEnabled(config->use_stderr);
stderrEnabled(config->use_stderr_for_log);
setAlarmShells(config->alarm_shells);
logStartInformation(config);
@ -749,16 +776,29 @@ bool start(Configuration *config)
printed_warning_ = true;
detectAndConfigureWMBusDevices(config);
if (wmbus_devices_.size() == 0)
if (!config->use_auto_detect)
{
info("(main) no wmbus device detected, waiting for a device to be plugged in.\n");
serial_manager_->expectDevicesToWork();
if (wmbus_devices_.size() == 0)
{
notice("(main) no wmbus device configured! Exiting.\n");
serial_manager_->stop();
}
}
else
{
if (wmbus_devices_.size() == 0)
{
notice("(main) no wmbus device detected, waiting for a device to be plugged in.\n");
}
}
// Every 2 seconds detect any plugged in or removed wmbus devices.
serial_manager_->startRegularCallback("HOT_PLUG_DETECTOR",
2,
[&](){
detectAndConfigureWMBusDevices(config);
if (serial_manager_ && config)
detectAndConfigureWMBusDevices(config);
});
if (config->daemon)

Wyświetl plik

@ -596,7 +596,7 @@ void SerialDeviceFile::close()
::close(fd_);
fd_ = -1;
manager_->closed(this);
verbose("(serialtty) closed %s %d\n", file_.c_str(), fd_);
verbose("(serialfile) closed %s %d\n", file_.c_str(), fd_);
}
void SerialDeviceFile::checkIfShouldReopen()
@ -895,6 +895,7 @@ void *SerialCommunicationManagerImp::eventLoop()
{
if (!d->skippingCallbacks())
{
trace("(SERIAL) select read on fd %d\n", d->fd());
FD_SET(d->fd(), &readfds);
}
if (!d->working()) all_working = false;

Wyświetl plik

@ -473,7 +473,10 @@ string mediaTypeJSON(int a_field_device_type)
Detected detectImstAmberCul(string file,
string suffix,
string linkmodes,
SerialCommunicationManager *handler)
SerialCommunicationManager *handler,
bool is_tty,
bool is_stdin,
bool is_file)
{
Detected detected {};
detected.device = { file, suffix, "" };
@ -505,7 +508,7 @@ Detected detectImstAmberCul(string file,
}
// We could not auto-detect either.
return { { file, suffix }, DEVICE_UNKNOWN, 0, false };
return { { file, suffix }, DEVICE_UNKNOWN, 0, false, is_tty, is_stdin, is_file };
}
/**
@ -564,6 +567,7 @@ Detected detectWMBusDeviceSetting(string file,
bool is_file = checkFileExists(file.c_str());
debug("(detect) is_tty=%d is_stdin=%d is_file=%d\n", is_tty, is_stdin, is_file);
if (!is_tty && !is_stdin && !is_file)
{
debug("(detect) not a valid device file %s\n", file.c_str());
@ -573,21 +577,21 @@ Detected detectWMBusDeviceSetting(string file,
bool override_tty = !is_tty;
if (suffix == "amb8465") return { { file, suffix }, DEVICE_AMB8465, 0, override_tty };
if (suffix == "im871a") return { { file, suffix }, DEVICE_IM871A, 0, override_tty };
if (suffix == "rfmrx2") return { { file, suffix }, DEVICE_RFMRX2, 0, override_tty };
if (suffix == "rtlwmbus") return { { file, suffix }, DEVICE_RTLWMBUS, 0, override_tty };
if (suffix == "rtl433") return { { file, suffix}, DEVICE_RTL433, 0, override_tty };
if (suffix == "cul") return { { file, suffix}, DEVICE_CUL, 0, override_tty };
if (suffix == "d1tc") return { { file, suffix}, DEVICE_D1TC, 0, override_tty };
if (suffix == "wmb13u") return { { file, suffix}, DEVICE_WMB13U, 0, override_tty };
if (suffix == "simulation") return { { file, suffix}, DEVICE_SIMULATOR, 0, override_tty };
if (suffix == "amb8465") return { { file, suffix }, DEVICE_AMB8465, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "im871a") return { { file, suffix }, DEVICE_IM871A, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "rfmrx2") return { { file, suffix }, DEVICE_RFMRX2, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "rtlwmbus") return { { file, suffix }, DEVICE_RTLWMBUS, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "rtl433") return { { file, suffix}, DEVICE_RTL433, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "cul") return { { file, suffix}, DEVICE_CUL, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "d1tc") return { { file, suffix}, DEVICE_D1TC, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "wmb13u") return { { file, suffix}, DEVICE_WMB13U, 0, override_tty, is_tty, is_stdin, is_file };
if (suffix == "simulation") return { { file, suffix}, DEVICE_SIMULATOR, 0, override_tty, is_tty, is_stdin, is_file };
// If the suffix is a number, then assume that it is a baud rate.
if (isNumber(suffix)) return { { file, suffix} , DEVICE_RAWTTY, atoi(suffix.c_str()), override_tty };
if (isNumber(suffix)) return { { file, suffix} , DEVICE_RAWTTY, atoi(suffix.c_str()), override_tty, is_tty, is_stdin, is_file };
// If the suffix is empty and its not a tty, then read raw telegrams from stdin or the file.
if (suffix == "" && !is_tty) return { { file, suffix}, DEVICE_RAWTTY, 0, true };
if (suffix == "" && !is_tty) return { { file, suffix}, DEVICE_RAWTTY, 0, true, is_tty, is_stdin, is_file };
if (suffix != "")
{
@ -597,7 +601,7 @@ Detected detectWMBusDeviceSetting(string file,
// Ok, we are left with a single /dev/ttyUSB0 lets talk to it
// to figure out what is connected to it. We currently only
// know how to detect Imst, Amber or CUL dongles.
return detectImstAmberCul(file, suffix, linkmodes, handler);
return detectImstAmberCul(file, suffix, linkmodes, handler, is_tty, is_stdin, is_file);
}
/*
@ -3378,7 +3382,7 @@ void WMBusCommonImplementation::disconnectedFromDevice()
{
if (is_working_)
{
info("(wmbus) lost %s closing %s\n", device().c_str(), toString(type()));
debug("(wmbus) disconnect %s closing %s\n", device().c_str(), toString(type()));
is_working_ = false;
}
}

Wyświetl plik

@ -97,12 +97,16 @@ struct Detected
// instead open the device->file as a file instead . This is to allows feeding the wmbus drivers
// using stdin or a file. This is primarily used for internal testing.
bool override_tty;
bool is_tty;
bool is_file;
bool is_stdin;
void set(WMBusDeviceType t, int br, bool ot)
{
type = t;
baudrate = br;
override_tty = ot;
is_tty = is_file = is_stdin = false;
}
};
@ -581,6 +585,9 @@ AccessCheck factoryResetAMB8465(string device, SerialCommunicationManager *handl
Detected detectImstAmberCul(string file,
string suffix,
string linkmodes,
SerialCommunicationManager *handler);
SerialCommunicationManager *handler,
bool is_tty,
bool is_stdin,
bool is_file);
#endif

Wyświetl plik

@ -10,7 +10,7 @@ TESTRESULT="ERROR"
cat simulations/simulation_additional_json.txt | grep '^{' > $TEST/test_expected.txt
$PROG --format=json --json_floor=5 --json_address="RoodRd 42" simulations/simulation_additional_json.txt \
MyTapWater multical21 76348799 "" \
> $TEST/test_output.txt
> $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
@ -29,7 +29,7 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test additional shell envs from cmdline"
TESTRESULT="ERROR"
$PROG --json_floor=5 --json_house="alfa beta" --listenvs=multical21 > $TEST/test_output.txt
$PROG --json_floor=5 --json_house="alfa beta" --listenvs=multical21 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
ENVS=$(cat $TEST/test_output.txt | tr '\n' ' ')
@ -65,7 +65,7 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
TESTNAME="Test additional json from wmbusmeters.conf and from meter file"
TESTRESULT="ERROR"
$PROG --useconfig=tests/config6 --device=simulations/simulation_shell.txt --listento=t1 > $TEST/test_output.txt
$PROG --useconfig=tests/config6 --device=simulations/simulation_shell.txt --listento=t1 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -16,7 +16,7 @@ cat $TEST/test_input.txt | $PROG --format=json "stdin:rtlwmbus" \
ApWater apator162 88888888 00000000000000000000000000000000 \
Vatten multical21 76348799 28F64A24988064A079AA2C807D6102AE \
Wasser supercom587 77777777 5065747220486F6C79737A6577736B69 \
> $TEST/test_output.txt
> $TEST/test_output.txt 2> $TEST/test_stderr.txt
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt

Wyświetl plik

@ -18,7 +18,7 @@ METERS="Wasser apator162 20202020 NOKEY
MyTapWatere apator162 27202020 NOKEY"
cat simulations/simulation_apas.txt | grep '^{' > $TEST/test_expected.txt
$PROG --format=json simulations/simulation_apas.txt $METERS > $TEST/test_output.txt
$PROG --format=json simulations/simulation_apas.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
@ -31,7 +31,7 @@ then
fi
cat simulations/simulation_apas.txt | grep '^|' | sed 's/^|//' > $TEST/test_expected.txt
$PROG --format=fields simulations/simulation_apas.txt $METERS > $TEST/test_output.txt
$PROG --format=fields simulations/simulation_apas.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9].[0-9][0-9]$/1111-11-11 11:11.11/' > $TEST/test_responses.txt

Wyświetl plik

@ -17,7 +17,7 @@ $PROG --format=json simulations/simulation_c1.txt \
MyElement qcaloric 78563412 "" \
Rum cma12w 66666666 "" \
My403Cooling multical403 78780102 "" \
> $TEST/test_output.txt
> $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -9,7 +9,7 @@ TESTRESULT="ERROR"
cat simulations/simulation_c1.txt | grep '^{' > $TEST/test_expected.txt
$PROG --useconfig=tests/config1 > $TEST/test_output.txt
$PROG --useconfig=tests/config1 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -9,7 +9,7 @@ TESTRESULT="ERROR"
cat simulations/simulation_conversionsadded.txt | grep '^{' > $TEST/test_expected.txt
$PROG --useconfig=tests/config4 > $TEST/test_output.txt
$PROG --useconfig=tests/config4 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -44,7 +44,7 @@ fi
TESTNAME="Test that setting multical21 to t1 fails"
TESTRESULT="ERROR"
MSG=$($PROG --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
MSG=$($PROG --listento=c1,t1 --usestdoutforlog simulations/simulation_t1_and_c1.txt \
MyTapWater multical21:t1 76348799 "" \
Wasser apator162:c1 20202020 "")
@ -60,7 +60,7 @@ fi
TESTNAME="Test that the warning for missed telegrams work"
TESTRESULT="ERROR"
MSG=$($PROG --s1 simulations/simulation_t1_and_c1.txt \
MSG=$($PROG --s1 --usestdoutforlog simulations/simulation_t1_and_c1.txt \
MyTapWater multical21:c1 76348799 "" \
Wasser apator162:t1 20202020 "" | tr -d ' \n')

Wyświetl plik

@ -196,7 +196,7 @@ fi
TESTNAME="Test listen and print any meter heard on stdout"
TESTRESULT="ERROR"
$PROG --t1 simulations/simulation_t1.txt 2>&1 > $LOGFILE
$PROG --t1 simulations/simulation_t1.txt 2> $LOGFILE
RES=$(diff $LOGFILE $LOGFILE_EXPECTED)

Wyświetl plik

@ -10,7 +10,7 @@ TESTRESULT="ERROR"
rm -f /tmp/MyTapWater
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
$PROG --meterfiles --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" > /dev/null
$PROG --meterfiles --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" > /dev/null 2> $TEST/test_stderr.txt
cat /tmp/MyTapWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ "$?" = "0" ]
@ -28,7 +28,7 @@ TESTRESULT="ERROR"
rm -rf /tmp/testmeters
mkdir /tmp/testmeters
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=name-id --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" > /dev/null
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=name-id --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" > /dev/null 2> $TEST/test_stderr.txt
cat /tmp/testmeters/MyTapWater-76348799 | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ "$?" = "0" ]
@ -46,7 +46,7 @@ TESTRESULT="ERROR"
rm -rf /tmp/testmeters
mkdir /tmp/testmeters
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=id --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 ""
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=id --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" 2> $TEST/test_stderr.txt
cat /tmp/testmeters/76348799 | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ "$?" = "0" ]
@ -65,7 +65,7 @@ TESTRESULT="ERROR"
rm -rf /tmp/testmeters
mkdir /tmp/testmeters
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=id --meterfilestimestamp=day --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 ""
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=id --meterfilestimestamp=day --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" 2> $TEST/test_stderr.txt
cat /tmp/testmeters/76348799_$(date +%Y-%m-%d) | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ "$?" = "0" ]
@ -80,7 +80,7 @@ if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
rm -rf /tmp/testmeters
mkdir /tmp/testmeters
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=id --meterfilestimestamp=minute --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 ""
$PROG --meterfiles=/tmp/testmeters --meterfilesnaming=id --meterfilestimestamp=minute --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" 2> $TEST/test_stderr.txt
cat /tmp/testmeters/76348799_$(date +%Y-%m-%d_%H:%M) | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_response.txt
if [ "$?" = "0" ]

Wyświetl plik

@ -8,9 +8,9 @@ mkdir -p testoutput
TEST=testoutput
SIM=simulations/simulation_c1.txt
$PROG --oneshot --verbose $SIM MyHeater multical302 67676767 NOKEY MyTapWater multical21 76348799 NOKEY > $TEST/test_output.txt
$PROG --oneshot --verbose $SIM MyHeater multical302 67676767 NOKEY MyTapWater multical21 76348799 NOKEY > $TEST/test_output.txt 2> $TEST/test_stderr.txt
RES=$(cat $TEST/test_output.txt | grep -o "(main) all meters have received at least one update, stopping." | tail -n 1)
RES=$(cat $TEST/test_stderr.txt | grep -o "(main) all meters have received at least one update, stopping." | tail -n 1)
if [ "$RES" = "(main) all meters have received at least one update, stopping." ]
then

Wyświetl plik

@ -8,7 +8,7 @@ TEST=testoutput
TESTNAME="Test shell invocation"
TESTRESULT="ERROR"
$PROG --shell='echo "$METER_JSON"' simulations/simulation_shell.txt MWW supercom587 12345678 "" > $TEST/test_output.txt
$PROG --shell='echo "$METER_JSON"' simulations/simulation_shell.txt MWW supercom587 12345678 "" > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt

Wyświetl plik

@ -7,7 +7,7 @@ mkdir -p $TEST
TESTNAME="Test shell in config file"
TESTRESULT="ERROR"
$PROG --useconfig=tests/config5 > $TEST/test_output.txt
$PROG --useconfig=tests/config5 > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then

Wyświetl plik

@ -36,7 +36,7 @@ METERS="MyWarmWater supercom587 12345678 NOKEY
Witer topaseskr 78563412 NOKEY"
cat simulations/simulation_t1.txt | grep '^{' > $TEST/test_expected.txt
$PROG --format=json simulations/simulation_t1.txt $METERS > $TEST/test_output.txt
$PROG --format=json simulations/simulation_t1.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
@ -51,7 +51,7 @@ then
fi
cat simulations/simulation_t1.txt | grep '^|' | sed 's/^|//' > $TEST/test_expected.txt
$PROG --format=fields simulations/simulation_t1.txt $METERS > $TEST/test_output.txt
$PROG --format=fields simulations/simulation_t1.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9].[0-9][0-9]$/1111-11-11 11:11.11/' > $TEST/test_responses.txt

Wyświetl plik

@ -21,7 +21,7 @@ cat > $TEST/test_expected.txt <<EOF
{"media":"reserved","meter":"lansensm","name":"Forren","id":"00010206","status":"OK","timestamp":"1111-11-11T11:11:11Z"}
EOF
$PROG --format=json simulations/simulation_unknown.txt $METERS > $TEST/test_output.txt
$PROG --format=json --usestdoutforlogging simulations/simulation_unknown.txt $METERS > $TEST/test_output.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt

Wyświetl plik

@ -16,9 +16,15 @@ cat $TEST/test_input.txt | $PROG --format=json "stdin:rtlwmbus" \
ApWater apator162 88888888 00000000000000000000000000000001 \
Vatten multical21 76348799 28F64A24988064A079AA2C807D6102AF \
Wasser supercom587 77777777 5065747220486F6C79737A6577736B6A \
> $TEST/test_output.txt
> $TEST/test_output.txt 2> $TEST/test_stderr.txt
cat $TEST/test_output.txt | grep -v '{"media' > $TEST/test_response.txt
if [ -s $TEST/test_output.txt ]
then
echo "Bad no stdout expected! But got bytes anyway!"
echo "ERROR: $TESTNAME"
TESTRESULT="ERROR"
exit 1
fi
cat <<EOF > $TEST/test_expected.txt
(wmbus) decrypted content failed check, did you use the correct decryption key? Ignoring telegram.
@ -26,7 +32,7 @@ cat <<EOF > $TEST/test_expected.txt
(wmbus) decrypted content failed check, did you use the correct decryption key? Ignoring telegram.
EOF
diff $TEST/test_expected.txt $TEST/test_response.txt
diff $TEST/test_expected.txt $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
echo "OK: $TESTNAME"