[PATCH 3/3] testsuite/dhcpd0x: Tests automatized
Gabriel.Moyano at dlr.de
Gabriel.Moyano at dlr.de
Tue Mar 31 09:30:38 UTC 2020
Hi Sebastian,
The short answer to your question (Do we see the environment in the test output after this change?) is no. I understood that the idea of the test is to verify that the hook is called. If this is not correct, the change can be removed.
Let me ask you if you consider useful the change in testsuite/dhcpcd02.
Regarding the path file, this could be changed to only "/".
Best regards,
Gabriel
-----Original Message-----
From: Sebastian Huber [mailto:sebastian.huber at embedded-brains.de]
Sent: Dienstag, 31. März 2020 11:12
To: Moyano Heredia, Victor Gabriel; devel at rtems.org
Subject: Re: [PATCH 3/3] testsuite/dhcpd0x: Tests automatized
On 31/03/2020 10:57, Moyano, Gabriel wrote:
> diff --git a/testsuite/dhcpcd01/test_main.c b/testsuite/dhcpcd01/test_main.c
> index 358b4ac8..f04c3270 100644
> --- a/testsuite/dhcpcd01/test_main.c
> +++ b/testsuite/dhcpcd01/test_main.c
> @@ -34,6 +34,7 @@
>
> #include <rtems.h>
> #include <rtems/dhcpcd.h>
> +#include <fcntl.h>
>
> #define TEST_NAME "LIBBSD DHCPCD 1"
>
> @@ -42,11 +43,17 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env)
> {
>
> (void)hook;
> + int fd;
> +
> + fd = open("/var/hook_out", O_CREAT | O_WRONLY,
> + S_IRWXU | S_IRWXG | S_IRWXO);
>
> while (*env != NULL) {
> - printf("%s\n", *env);
> + dprintf(fd, "%s\n", *env);
Do we see the environment in the test output after this change? What
happens if "/var" doesn't exist? I would do the synchronization with the
main thread with an event or semaphore instead of a file.
> ++env;
> }
> +
> + close(fd);
> }
>
> static rtems_dhcpcd_hook dhcpcd_hook = {
> @@ -57,11 +64,22 @@ static rtems_dhcpcd_hook dhcpcd_hook = {
> static void
> test_main(void)
> {
> + int fd;
>
> + // Add hook
> rtems_dhcpcd_add_hook(&dhcpcd_hook);
What is the purpose of this comment? For a function with the name
rtems_dhcpcd_add_hook() it should be obvious that it adds a hook.
>
> - rtems_task_delete(RTEMS_SELF);
> - assert(0);
> + // Verify whether an output file is created by the hook
Please use the FreeBSD coding style.
> + while(true)
> + {
> + fd = open("/var/hook_out", O_RDONLY);
> + if (fd >= 0)
> + {
> + close(fd);
> + exit(0);
> + }
> + rtems_task_wake_after(RTEMS_MILLISECONDS_TO_TICKS(1000));
> + }
> }
More information about the devel
mailing list