platform_bootable_recovery/tests/unit
Tao Bao 1700cc46b5 Fix the arguments passed to getopt_long(3).
The getopt_long(3) implementation in Android (upstream freebsd) expects
a null-terminated array while parsing long options with required args.

  if (long_options[match].has_arg == required_argument) {
    optarg = nargv[optind++];
  }
  ...
  if (long_options[match].has_arg == required_argument && optarg == NULL) {
    return (BADARG);
  }

This seems to make sense in practice, as getopt(3) takes the first two
arguments of argc and argv that are "as passed to the main() function on
program invocation", and both of C and C++ spec say "the value of
argv[argc] shall be 0".

Prior to the CL, we may run into undefined behavior on malformed input
command line (e.g. missing arg for an option that requires one). This CL
fixes the issue by always appending a nullptr to the argument list (but
without counting that into argc).

Test: Build and boot into recovery with commands.
Change-Id: Ic6c37548f4db2f30aeabd40f387ca916eeca5392
2018-07-17 12:16:53 -07:00
..
applypatch_test.cpp tests: Clean up the temporary dirs post-run. 2018-07-12 12:54:15 -07:00
asn1_decoder_test.cpp Refactor asn1_decoder functions into a class. 2017-03-21 15:17:43 -07:00
commands_test.cpp updater: Add ABORT command. 2018-07-07 04:12:19 +00:00
dirutil_test.cpp otautil: Rename dir/sys/thermal utils. 2018-05-03 23:17:29 -07:00
locale_test.cpp Add the missing sr-Latn into png files and rename the png locale header 2017-03-24 16:54:52 -07:00
rangeset_test.cpp tests: Specify the death test style to avoid flakiness. 2018-06-05 14:06:59 -07:00
screen_ui_test.cpp tests: Clean up the temporary dirs post-run. 2018-07-12 12:54:15 -07:00
sysutil_test.cpp Fix the arguments passed to getopt_long(3). 2018-07-17 12:16:53 -07:00
zip_test.cpp otautil: Rename dir/sys/thermal utils. 2018-05-03 23:17:29 -07:00