From 3ac4ef4ab30c88bb7c5d4be14219d2be98ec2bbc Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 20 Dec 2014 18:52:16 +0100 Subject: Add S.BUS2 unit test, needs better coverage against logfile --- unittests/sbus2_test.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'unittests/sbus2_test.cpp') diff --git a/unittests/sbus2_test.cpp b/unittests/sbus2_test.cpp index e2c18369c..ba075f8b3 100644 --- a/unittests/sbus2_test.cpp +++ b/unittests/sbus2_test.cpp @@ -11,14 +11,20 @@ int main(int argc, char *argv[]) { warnx("SBUS2 test started"); - if (argc < 2) - errx(1, "Need a filename for the input file"); + char *filepath = 0; - warnx("loading data from: %s", argv[1]); + if (argc < 2) { + warnx("Using default input file"); + filepath = "testdata/sbus2_r7008SB.txt"; + } else { + filepath = argv[1]; + } + + warnx("loading data from: %s", filepath); FILE *fp; - fp = fopen(argv[1],"rt"); + fp = fopen(filepath,"rt"); if (!fp) errx(1, "failed opening file"); @@ -47,7 +53,7 @@ int main(int argc, char *argv[]) { while (EOF != (ret = fscanf(fp, "%f,%x,,", &f, &x))) { if (((f - last_time) * 1000 * 1000) > 3000) { partial_frame_count = 0; - warnx("FRAME RESET\n\n"); + //warnx("FRAME RESET\n\n"); } frame[partial_frame_count] = x; @@ -69,8 +75,10 @@ int main(int argc, char *argv[]) { if (ret == EOF) { warnx("Test finished, reached end of file"); + ret = 0; } else { warnx("Test aborted, errno: %d", ret); } + return ret; } -- cgit v1.2.3