Skip to contentSkip to conversation

test usage() ?

Openvpn-devel Илья Шипицин 2 participants 2 messages Jun 23, 2017

lore
Share & tools
lore
#1 lore raw
Quoted 9 lines · Илья Шипицин

Hello,

following to
https://github.com/OpenVPN/openvpn/commit/49629380a7bdba25c24c9d410b79946fe29249f0

I spent some days on trying to get cmocka to test usage(), I gave up :-) now, I think, we should just add "src/openvpn/openvpn --help" to .travis.yml

the question is - can we rely on exit status "1" here ?

Yes.

Quoted 7 lines
$ src/openvpn/openvpn --help >/dev/null
$ echo $?
1
$

why does "1" mean "ok" here ?

At the end of the usage() function, it calls openvpn_exit(OPENVPN_EXIT_STATUS_USAGE). OPENVPN_EXIT_STATUS_USAGE is defined to be 1 in error.h. And the argument given to openvpn_exit() is an integer which is used as the exit code when OpenVPN stops running.

It is not uncommon that usage() returns a non-0. But that varies from project to project. In OpenVPN context 1 usually can be interpreted as "no tunnel was started".

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Technologies, Inc