From e1967c7ba42c08de1925e958b3dfa0b5c430dbfd Mon Sep 17 00:00:00 2001 From: Bui Nguyen Quoc Thanh Date: Thu, 6 Jun 2019 11:33:03 +0700 Subject: dlt-test: Add options Support two options for dlt-test-filestransfer to specify the absolute path to tested files. Signed-off-by: Bui Nguyen Quoc Thanh --- src/tests/dlt-test-filetransfer.c | 47 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/tests/dlt-test-filetransfer.c b/src/tests/dlt-test-filetransfer.c index 05a54d9..ec157f2 100644 --- a/src/tests/dlt-test-filetransfer.c +++ b/src/tests/dlt-test-filetransfer.c @@ -27,7 +27,7 @@ /******************************************************************************* ** ** -** SRC-MODULE: dlt-test-client.c ** +** SRC-MODULE: dlt-test-filetransfer.c ** ** ** ** TARGET : linux ** ** ** @@ -375,9 +375,25 @@ int testFile3Run3() return 0; } +void usage() +{ + char version[255]; + + dlt_get_version(version, 255); + + printf("Usage: dlt-test-filestransfer [options]\n"); + printf("Test filestransfer application by transfering files.\n"); + printf("%s \n", version); + printf("Options:\n"); + printf(" -h display help information\n"); + printf(" -t absolute path to a text file\n"); + printf(" -i absolute path to an image file\n"); +} + /*!Main program dlt-test-filestransfer starts here */ -int main(void) +int main(int argc, char* argv[]) { + int c; /*First file contains some text */ file1 = "/usr/local/share/dlt-filetransfer/dlt-test-filetransfer-file"; /*Second file is a picture */ @@ -389,6 +405,33 @@ int main(void) /*Third file doesn't exist. Just to test the reaction when the file isn't available. */ file3_3 = "dlt-test-filetransfer-doesntExist_3"; + while((c = getopt(argc, argv, "ht:i:")) != -1) + { + switch (c) + { + case 't': + { + file1 = optarg; + break; + } + case 'i': + { + file2 = optarg; + break; + } + case 'h': + { + usage(); + return 0; + } + default: + { + usage(); + return -1; + } + } + } + /*Register the application at the dlt-daemon */ DLT_REGISTER_APP("FLTR", "Test Application filetransfer"); -- cgit v1.2.1