ValentinSidorov / DeLorean_Team

Source project automotive BASECAMP
MIT License
0 stars 2 forks source link

Serhii Shmahlii #21

Closed Storegist closed 2 years ago

Storegist commented 2 years ago

So this is a separate application (in same codebase) that will help to test our Execution Manager https://github.com/ValentinSidorov/DeLorean_Team/tree/SerhiiShmahlii/tests/integration

Depending on the keys used, the program should work in the following combinations:

(how to launch each particular option is described in the brackets )

No keys: Output "Hello world" to stdout and file and exit.;          (./test_prog )                                                                        
--text='some text' Output "some text" to stdout and file and exit;     (./test_prog --text="some text" ) 

--text='text1' --other-text='text2' Output "text1 text2" to stdout and file and exit;  ((./test_prog --text1="some text"   --text2="some text")

--text='some text' -loop Output "some text" in an endless loop to stdout and file with an interval of 5 seconds (./test_prog --text="some words" --loop)
andrey-berdnik commented 2 years ago

Еще не запускал, но есть предложение:

Было бы лучше ( и как путь доработки). Использовать ключи запуска не в формате 1,2,3... а согласно тикета ./test_prog --text='some text' --other-text='text2' -loop Output "some text"

Для решения этой задачи подойдут библиотеки описанные здесь https://stackoverflow.com/questions/9642732/parsing-command-line-arguments-in-c

В частности эта выглядит неплохо и довольно проста в реализации https://www.gnu.org/software/libc/manual/html_node/Getopt.html

Storegist commented 2 years ago

Оk, I will try to correct it

andrey-berdnik commented 2 years ago

Сценарий 1. строка запуска: ./test_prog ожидаемый результат: Hello world Полученный результат: image Комментарий: вместо одного сообщения выводит несколько (мелочи) и выводит сообщение о созданном файле. Лишнее сообщение будет мешать в автоматизированном тестировании.

Сценарий 2. строка запуска: ./test_prog --text='soome text' ожидаемый результат: soome text Полученный результат: image Комментарий: должно выводить только значение аргумента, без ключей

Сценарий 3. строка запуска: ./test_prog --text='text1' --other-text='text2' ожидаемый результат: text1 text2 Полученный результат: image Комментарий: приложение не обрабатывает второй аргумент и завершает свою работу с "Segmentation fault: 11"

Сценарий 3. строка запуска: ./test_prog --text='text1' --loop ожидаемый результат: text1 text1 text1 (бесконечный вывод text1 с задержкой между выводами 5 секунд) Полученный результат: image Комментарий: все то же что и в предыдущих случаях. Но нам важно получиь приложение, которое добровольно не завершает свое выполнение никогда

Так же есть тревожные замечания от cppchecker image такое не стоит игнорировать

zonmen commented 2 years ago

I agree with all, that Andrey said and checked your program. You check arguments, if its number is three you need to add argv[2](last argument) to string, not argv[3](numbering starts from 0) and other elements of argv too.

Storegist commented 2 years ago

I have corrected everything. Please check

zonmen commented 2 years ago

Okey, it's cool and I have only recommendation:

  1. Rename name of the files from filename1, filename2 ... to something like "output_without_argument.txt", "output_arg1", etc.
  2. Rename console and file output. You just put "text1" or something else, I think it would be better, if you diveded output to "cout_text" and in files "file_text". So just add cout- and file- prefics