tests/gpio: don't call risk function

According to Coverity, rand() is a risk function.
So we use another method to generate random value.

Coverity-CID: 160070

Change-Id: Icb7e06cd43cb8bade6596cc37e9d04bfc59e1de7
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
This commit is contained in:
Qiu Peiyang 2017-01-23 13:38:20 +08:00 committed by Anas Nashif
commit cbeac3e97d
2 changed files with 3 additions and 3 deletions

View file

@ -1,3 +1,4 @@
CONFIG_GPIO=y
CONFIG_ZTEST=y
CONFIG_NEWLIB_LIBC=y
CONFIG_RANDOM_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -12,7 +12,6 @@
* @}
*/
#include <stdlib.h>
#include <inttypes.h>
#include "test_gpio.h"
@ -32,7 +31,7 @@ void test_gpio_pin_read_write(void)
int i = 0;
while (i++ < 32) {
val_write = rand() % 2;
val_write = sys_rand32_get() / 3 % 2;
assert_true(gpio_pin_write(dev, PIN_OUT, val_write) == 0,
"write data fail");
TC_PRINT("write: %" PRIu32 "\n", val_write);