tests: use appropriate sys_randX_get()

use the appropriate sys_randX_get() instead
of always sys_rand32_get().

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2024-04-03 16:06:05 +02:00 committed by Mahesh Mahadevan
parent a9afee1d12
commit e354927895
37 changed files with 58 additions and 83 deletions

View file

@ -216,7 +216,7 @@ static k_timeout_t randomize_t(k_timeout_t t)
static void microdelay(void) static void microdelay(void)
{ {
static volatile int microdelay_cnt; static volatile int microdelay_cnt;
uint32_t repeat = sys_rand32_get() & 0xff; uint8_t repeat = sys_rand8_get();
for (int i = 0; i < repeat; i++) { for (int i = 0; i < repeat; i++) {
microdelay_cnt++; microdelay_cnt++;

View file

@ -244,25 +244,11 @@ do { \
static int myrand(void *rng_state, unsigned char *output, size_t len) static int myrand(void *rng_state, unsigned char *output, size_t len)
{ {
size_t use_len;
int rnd;
if (rng_state != NULL) { if (rng_state != NULL) {
rng_state = NULL; rng_state = NULL;
} }
while (len > 0) { sys_rand_get(output, len);
use_len = len;
if (use_len > sizeof(int)) {
use_len = sizeof(int);
}
rnd = sys_rand32_get();
memcpy(output, &rnd, use_len);
output += use_len;
len -= use_len;
}
return(0); return(0);
} }

View file

@ -616,14 +616,7 @@ int default_CSPRNG(uint8_t *dest, unsigned int size)
/* This is not a CSPRNG, but it's the only thing available in the /* This is not a CSPRNG, but it's the only thing available in the
* system at this point in time. */ * system at this point in time. */
while (size) { sys_rand_get(dest, size);
uint32_t len = size >= sizeof(uint32_t) ? sizeof(uint32_t) : size;
uint32_t rv = sys_rand32_get();
memcpy(dest, &rv, len);
dest += len;
size -= len;
}
return 1; return 1;
} }

View file

@ -113,7 +113,7 @@ ZTEST(test_smbus_emul, test_byte)
ret = smbus_quick(dev, PERIPH_ADDR, 1); ret = smbus_quick(dev, PERIPH_ADDR, 1);
zassert_ok(ret, "SMBus Quick failed"); zassert_ok(ret, "SMBus Quick failed");
snd_byte = (uint8_t)sys_rand32_get(); snd_byte = sys_rand8_get();
ret = smbus_byte_write(dev, PERIPH_ADDR, snd_byte); ret = smbus_byte_write(dev, PERIPH_ADDR, snd_byte);
zassert_ok(ret, "SMBus Byte Write failed"); zassert_ok(ret, "SMBus Byte Write failed");
@ -141,7 +141,7 @@ ZTEST(test_smbus_emul, test_word)
zassert_not_null(dev, "Device not found"); zassert_not_null(dev, "Device not found");
snd_word = (uint16_t)sys_rand32_get(); snd_word = sys_rand16_get();
ret = smbus_word_data_write(dev, PERIPH_ADDR, 0, snd_word); ret = smbus_word_data_write(dev, PERIPH_ADDR, 0, snd_word);
zassert_ok(ret, "SMBus Word Data Write failed"); zassert_ok(ret, "SMBus Word Data Write failed");
@ -153,7 +153,7 @@ ZTEST(test_smbus_emul, test_word)
/* Test 2 byte writes following word read */ /* Test 2 byte writes following word read */
snd_byte = (uint8_t)sys_rand32_get(); snd_byte = sys_rand8_get();
ret = smbus_byte_data_write(dev, PERIPH_ADDR, 0, snd_byte); ret = smbus_byte_data_write(dev, PERIPH_ADDR, 0, snd_byte);
zassert_ok(ret, "SMBus Byte Data Write failed"); zassert_ok(ret, "SMBus Byte Data Write failed");
@ -174,7 +174,7 @@ ZTEST(test_smbus_emul, test_proc_call)
zassert_not_null(dev, "Device not found"); zassert_not_null(dev, "Device not found");
snd_word = (uint16_t)sys_rand32_get(); snd_word = sys_rand16_get();
zassert_not_equal(snd_word, 0, "Random number generator misconfgured"); zassert_not_equal(snd_word, 0, "Random number generator misconfgured");
ret = smbus_pcall(dev, PERIPH_ADDR, 0x0, snd_word, &rcv_word); ret = smbus_pcall(dev, PERIPH_ADDR, 0x0, snd_word, &rcv_word);
@ -194,9 +194,7 @@ ZTEST(test_smbus_emul, test_block)
zassert_not_null(dev, "Device not found"); zassert_not_null(dev, "Device not found");
for (int i = 0; i < sizeof(snd_block); i++) { sys_rand_get(snd_block, sizeof(snd_block));
snd_block[i] = (uint8_t)sys_rand32_get();
}
snd_count = sizeof(snd_block); snd_count = sizeof(snd_block);
@ -221,9 +219,7 @@ ZTEST(test_smbus_emul, test_block_pcall)
zassert_not_null(dev, "Device not found"); zassert_not_null(dev, "Device not found");
for (int i = 0; i < sizeof(snd_block); i++) { sys_rand_get(snd_block, sizeof(snd_block));
snd_block[i] = (uint8_t)sys_rand32_get();
}
snd_count = SMBUS_BLOCK_BYTES_MAX / 2; snd_count = SMBUS_BLOCK_BYTES_MAX / 2;
ret = smbus_block_pcall(dev, PERIPH_ADDR, 0, snd_count, snd_block, ret = smbus_block_pcall(dev, PERIPH_ADDR, 0, snd_count, snd_block,

View file

@ -294,7 +294,7 @@ static void poll_out_timer_handler(struct k_timer *timer)
k_timer_stop(timer); k_timer_stop(timer);
k_sem_give(&data->sem); k_sem_give(&data->sem);
} else { } else {
k_timer_start(timer, K_USEC(250 + (sys_rand32_get() % 800)), k_timer_start(timer, K_USEC(250 + (sys_rand16_get() % 800)),
K_NO_WAIT); K_NO_WAIT);
} }
} }

View file

@ -72,7 +72,7 @@ static void stress_handler(struct k_p4wq_work *item)
/* Pick 0-3 random item slots and submit them if they aren't /* Pick 0-3 random item slots and submit them if they aren't
* already. Make sure we always have at least one active. * already. Make sure we always have at least one active.
*/ */
int num_tries = sys_rand32_get() % 4; int num_tries = sys_rand8_get() % 4;
for (int i = 0; (active_items == 0) || (i < num_tries); i++) { for (int i = 0; (active_items == 0) || (i < num_tries); i++) {
int ii = sys_rand32_get() % MAX_ITEMS; int ii = sys_rand32_get() % MAX_ITEMS;

View file

@ -424,7 +424,7 @@ bool stress_read(void *user_data, uint32_t cnt, bool last, int prio)
struct stress_data *ctx = (struct stress_data *)user_data; struct stress_data *ctx = (struct stress_data *)user_data;
char buf[128]; char buf[128];
int len; int len;
int rpt = (sys_rand32_get() & 3) + 1; int rpt = (sys_rand8_get() & 3) + 1;
for (int i = 0; i < rpt; i++) { for (int i = 0; i < rpt; i++) {
len = spsc_pbuf_read(ctx->pbuf, buf, (uint16_t)sizeof(buf)); len = spsc_pbuf_read(ctx->pbuf, buf, (uint16_t)sizeof(buf));
@ -447,8 +447,8 @@ bool stress_write(void *user_data, uint32_t cnt, bool last, int prio)
{ {
struct stress_data *ctx = (struct stress_data *)user_data; struct stress_data *ctx = (struct stress_data *)user_data;
char buf[128]; char buf[128];
uint16_t len = 1 + (sys_rand32_get() % (ctx->capacity / 4)); uint16_t len = 1 + (sys_rand16_get() % (ctx->capacity / 4));
int rpt = (sys_rand32_get() & 1) + 1; int rpt = (sys_rand8_get() & 1) + 1;
zassert_true(len < sizeof(buf), "len:%d %d", len, ctx->capacity); zassert_true(len < sizeof(buf), "len:%d %d", len, ctx->capacity);
@ -490,7 +490,7 @@ bool stress_claim_free(void *user_data, uint32_t cnt, bool last, int prio)
struct stress_data *ctx = (struct stress_data *)user_data; struct stress_data *ctx = (struct stress_data *)user_data;
char *buf; char *buf;
uint16_t len; uint16_t len;
int rpt = sys_rand32_get() % 0x3; int rpt = sys_rand8_get() % 0x3;
for (int i = 0; i < rpt; i++) { for (int i = 0; i < rpt; i++) {
len = spsc_pbuf_claim(ctx->pbuf, &buf); len = spsc_pbuf_claim(ctx->pbuf, &buf);
@ -512,7 +512,7 @@ bool stress_claim_free(void *user_data, uint32_t cnt, bool last, int prio)
bool stress_alloc_commit(void *user_data, uint32_t cnt, bool last, int prio) bool stress_alloc_commit(void *user_data, uint32_t cnt, bool last, int prio)
{ {
struct stress_data *ctx = (struct stress_data *)user_data; struct stress_data *ctx = (struct stress_data *)user_data;
uint32_t rnd = sys_rand32_get(); uint16_t rnd = sys_rand16_get();
uint16_t len = 1 + (rnd % (ctx->capacity / 4)); uint16_t len = 1 + (rnd % (ctx->capacity / 4));
int rpt = rnd % 0x3; int rpt = rnd % 0x3;
char *buf; char *buf;

View file

@ -70,7 +70,7 @@ static uint8_t *net_arp_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -446,7 +446,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int eth_init(const struct device *dev) static int eth_init(const struct device *dev)

View file

@ -983,7 +983,7 @@ static uint8_t *net_context_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -82,7 +82,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
} }
data->ll_addr.addr = data->mac_addr; data->ll_addr.addr = data->mac_addr;
@ -173,7 +173,7 @@ static void eth_fake_iface_init(struct net_if *iface)
ctx->mac_address[2] = 0x5E; ctx->mac_address[2] = 0x5E;
ctx->mac_address[3] = 0x00; ctx->mac_address[3] = 0x00;
ctx->mac_address[4] = 0x53; ctx->mac_address[4] = 0x53;
ctx->mac_address[5] = sys_rand32_get(); ctx->mac_address[5] = sys_rand8_get();
net_if_set_link_addr(iface, ctx->mac_address, net_if_set_link_addr(iface, ctx->mac_address,
sizeof(ctx->mac_address), sizeof(ctx->mac_address),

View file

@ -88,7 +88,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
} }
data->ll_addr.addr = data->mac_addr; data->ll_addr.addr = data->mac_addr;

View file

@ -84,7 +84,7 @@ static uint8_t *net_test_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -129,7 +129,7 @@ static uint8_t *net_test_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -169,7 +169,7 @@ static uint8_t *net_test_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;
@ -1179,7 +1179,7 @@ ZTEST(net_ipv6, test_change_ll_addr)
ll_iface->addr[2] = 0x5E; ll_iface->addr[2] = 0x5E;
ll_iface->addr[3] = 0x00; ll_iface->addr[3] = 0x00;
ll_iface->addr[4] = 0x53; ll_iface->addr[4] = 0x53;
ll_iface->addr[5] = sys_rand32_get(); ll_iface->addr[5] = sys_rand8_get();
} }
ZTEST(net_ipv6, test_dad_timeout) ZTEST(net_ipv6, test_dad_timeout)

View file

@ -938,7 +938,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
} }
data->ll_addr.addr = data->mac_addr; data->ll_addr.addr = data->mac_addr;

View file

@ -91,7 +91,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
} }
return data->mac_addr; return data->mac_addr;

View file

@ -89,7 +89,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
} }
data->ll_addr.addr = data->mac_addr; data->ll_addr.addr = data->mac_addr;

View file

@ -193,7 +193,7 @@ static int publish(enum mqtt_qos qos)
param.message.payload.data = get_mqtt_payload(qos); param.message.payload.data = get_mqtt_payload(qos);
param.message.payload.len = param.message.payload.len =
strlen(param.message.payload.data); strlen(param.message.payload.data);
param.message_id = sys_rand32_get(); param.message_id = sys_rand16_get();
param.dup_flag = 0U; param.dup_flag = 0U;
param.retain_flag = 0U; param.retain_flag = 0U;

View file

@ -325,7 +325,7 @@ static int test_subscribe(void)
topic.qos = MQTT_QOS_1_AT_LEAST_ONCE; topic.qos = MQTT_QOS_1_AT_LEAST_ONCE;
sub.list = &topic; sub.list = &topic;
sub.list_count = 1U; sub.list_count = 1U;
sub.message_id = sys_rand32_get(); sub.message_id = sys_rand16_get();
rc = mqtt_subscribe(&client_ctx, &sub); rc = mqtt_subscribe(&client_ctx, &sub);
if (rc != 0) { if (rc != 0) {
@ -354,7 +354,7 @@ static int test_publish(enum mqtt_qos qos)
strlen(param.message.topic.topic.utf8); strlen(param.message.topic.topic.utf8);
param.message.payload.data = (uint8_t *)payload; param.message.payload.data = (uint8_t *)payload;
param.message.payload.len = payload_left; param.message.payload.len = payload_left;
param.message_id = sys_rand32_get(); param.message_id = sys_rand16_get();
param.dup_flag = 0U; param.dup_flag = 0U;
param.retain_flag = 0U; param.retain_flag = 0U;
@ -388,7 +388,7 @@ static int test_unsubscribe(void)
topic.topic.size = strlen(topic.topic.utf8); topic.topic.size = strlen(topic.topic.utf8);
unsub.list = &topic; unsub.list = &topic;
unsub.list_count = 1U; unsub.list_count = 1U;
unsub.message_id = sys_rand32_get(); unsub.message_id = sys_rand16_get();
rc = mqtt_unsubscribe(&client_ctx, &unsub); rc = mqtt_unsubscribe(&client_ctx, &unsub);
if (rc != 0) { if (rc != 0) {

View file

@ -251,7 +251,7 @@ static int test_subscribe(void)
topic.qos = MQTT_QOS_1_AT_LEAST_ONCE; topic.qos = MQTT_QOS_1_AT_LEAST_ONCE;
sub.list = &topic; sub.list = &topic;
sub.list_count = 1U; sub.list_count = 1U;
sub.message_id = sys_rand32_get(); sub.message_id = sys_rand16_get();
rc = mqtt_subscribe(&client_ctx, &sub); rc = mqtt_subscribe(&client_ctx, &sub);
if (rc != 0) { if (rc != 0) {
@ -274,7 +274,7 @@ static int test_unsubscribe(void)
topic.topic.size = strlen(topic.topic.utf8); topic.topic.size = strlen(topic.topic.utf8);
unsub.list = &topic; unsub.list = &topic;
unsub.list_count = 1U; unsub.list_count = 1U;
unsub.message_id = sys_rand32_get(); unsub.message_id = sys_rand16_get();
rc = mqtt_unsubscribe(&client_ctx, &unsub); rc = mqtt_unsubscribe(&client_ctx, &unsub);
if (rc != 0) { if (rc != 0) {

View file

@ -87,7 +87,7 @@ static uint8_t *net_test_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -35,7 +35,7 @@ static void fake_dev_iface_init(struct net_if *iface)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
net_if_set_link_addr(iface, mac_addr, 6, NET_LINK_ETHERNET); net_if_set_link_addr(iface, mac_addr, 6, NET_LINK_ETHERNET);

View file

@ -66,7 +66,7 @@ static uint8_t *fake_dev_get_mac(struct fake_dev_context *ctx)
ctx->mac_addr[2] = 0x5E; ctx->mac_addr[2] = 0x5E;
ctx->mac_addr[3] = 0x00; ctx->mac_addr[3] = 0x00;
ctx->mac_addr[4] = 0x53; ctx->mac_addr[4] = 0x53;
ctx->mac_addr[5] = sys_rand32_get(); ctx->mac_addr[5] = sys_rand8_get();
} }
return ctx->mac_addr; return ctx->mac_addr;

View file

@ -147,7 +147,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int eth_init(const struct device *dev) static int eth_init(const struct device *dev)

View file

@ -113,7 +113,7 @@ static uint8_t *net_route_get_mac(const struct device *dev)
route->mac_addr[2] = 0x5E; route->mac_addr[2] = 0x5E;
route->mac_addr[3] = 0x00; route->mac_addr[3] = 0x00;
route->mac_addr[4] = 0x53; route->mac_addr[4] = 0x53;
route->mac_addr[5] = sys_rand32_get(); route->mac_addr[5] = sys_rand8_get();
} }
route->ll_addr.addr = route->mac_addr; route->ll_addr.addr = route->mac_addr;
@ -285,7 +285,7 @@ static void test_init(void)
sizeof(struct in6_addr)); sizeof(struct in6_addr));
dest_addresses[i].s6_addr[14] = i + 1; dest_addresses[i].s6_addr[14] = i + 1;
dest_addresses[i].s6_addr[15] = sys_rand32_get(); dest_addresses[i].s6_addr[15] = sys_rand8_get();
} }
} }

View file

@ -154,7 +154,7 @@ static uint8_t *net_route_mcast_get_mac(const struct device *dev)
cfg->mac_addr[2] = 0x5E; cfg->mac_addr[2] = 0x5E;
cfg->mac_addr[3] = 0x00; cfg->mac_addr[3] = 0x00;
cfg->mac_addr[4] = 0x53; cfg->mac_addr[4] = 0x53;
cfg->mac_addr[5] = sys_rand32_get(); cfg->mac_addr[5] = sys_rand8_get();
} }
cfg->ll_addr.addr = cfg->mac_addr; cfg->ll_addr.addr = cfg->mac_addr;

View file

@ -78,7 +78,7 @@ static uint8_t *net_udp_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -56,7 +56,7 @@ static uint8_t *fake_dev_get_mac(struct fake_dev_context *ctx)
ctx->mac_addr[2] = 0x5E; ctx->mac_addr[2] = 0x5E;
ctx->mac_addr[3] = 0x00; ctx->mac_addr[3] = 0x00;
ctx->mac_addr[4] = 0x53; ctx->mac_addr[4] = 0x53;
ctx->mac_addr[5] = sys_rand32_get(); ctx->mac_addr[5] = sys_rand8_get();
} }
return ctx->mac_addr; return ctx->mac_addr;

View file

@ -254,7 +254,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int eth_init(const struct device *dev) static int eth_init(const struct device *dev)

View file

@ -141,7 +141,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int eth_init(const struct device *dev) static int eth_init(const struct device *dev)

View file

@ -80,7 +80,7 @@ static uint8_t *net_udp_get_mac(const struct device *dev)
context->mac_addr[2] = 0x5E; context->mac_addr[2] = 0x5E;
context->mac_addr[3] = 0x00; context->mac_addr[3] = 0x00;
context->mac_addr[4] = 0x53; context->mac_addr[4] = 0x53;
context->mac_addr[5] = sys_rand32_get(); context->mac_addr[5] = sys_rand8_get();
} }
return context->mac_addr; return context->mac_addr;

View file

@ -175,7 +175,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int eth_init(const struct device *dev) static int eth_init(const struct device *dev)
@ -209,7 +209,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
} }
data->ll_addr.addr = data->mac_addr; data->ll_addr.addr = data->mac_addr;
@ -533,12 +533,12 @@ static bool add_to_arp(struct net_if *iface, struct in_addr *addr)
#if defined(CONFIG_NET_ARP) #if defined(CONFIG_NET_ARP)
struct net_eth_addr lladdr; struct net_eth_addr lladdr;
lladdr.addr[0] = sys_rand32_get(); lladdr.addr[0] = sys_rand8_get();
lladdr.addr[1] = 0x08; lladdr.addr[1] = 0x08;
lladdr.addr[2] = 0x09; lladdr.addr[2] = 0x09;
lladdr.addr[3] = 0x10; lladdr.addr[3] = 0x10;
lladdr.addr[4] = 0x11; lladdr.addr[4] = 0x11;
lladdr.addr[5] = sys_rand32_get(); lladdr.addr[5] = sys_rand8_get();
return arp_add(iface, addr, &lladdr); return arp_add(iface, addr, &lladdr);
#else #else

View file

@ -179,7 +179,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int eth_vlan_init(const struct device *dev) static int eth_vlan_init(const struct device *dev)
@ -225,7 +225,7 @@ static uint8_t *net_iface_get_mac(const struct device *dev)
data->mac_addr[2] = 0x5E; data->mac_addr[2] = 0x5E;
data->mac_addr[3] = 0x00; data->mac_addr[3] = 0x00;
data->mac_addr[4] = 0x53; data->mac_addr[4] = 0x53;
data->mac_addr[5] = sys_rand32_get(); data->mac_addr[5] = sys_rand8_get();
data->ll_addr.addr = data->mac_addr; data->ll_addr.addr = data->mac_addr;
data->ll_addr.len = 6U; data->ll_addr.len = 6U;

View file

@ -87,7 +87,7 @@ static void generate_mac(uint8_t *mac_addr)
mac_addr[2] = 0x5E; mac_addr[2] = 0x5E;
mac_addr[3] = 0x00; mac_addr[3] = 0x00;
mac_addr[4] = 0x53; mac_addr[4] = 0x53;
mac_addr[5] = sys_rand32_get(); mac_addr[5] = sys_rand8_get();
} }
static int wifi_init(const struct device *dev) static int wifi_init(const struct device *dev)

View file

@ -211,7 +211,7 @@ bool stress_read(void *user_data, uint32_t cnt, bool last, int prio)
struct stress_data *ctx = (struct stress_data *)user_data; struct stress_data *ctx = (struct stress_data *)user_data;
char buf[STRESS_LEN_MAX]; char buf[STRESS_LEN_MAX];
int len; int len;
int rpt = (sys_rand32_get() & 3) + 1; int rpt = (sys_rand8_get() & 3) + 1;
for (int i = 0; i < rpt; i++) { for (int i = 0; i < rpt; i++) {
len = pbuf_read(ctx->pbuf, buf, (uint16_t)sizeof(buf)); len = pbuf_read(ctx->pbuf, buf, (uint16_t)sizeof(buf));
@ -235,8 +235,8 @@ bool stress_write(void *user_data, uint32_t cnt, bool last, int prio)
struct stress_data *ctx = (struct stress_data *)user_data; struct stress_data *ctx = (struct stress_data *)user_data;
char buf[STRESS_LEN_MAX]; char buf[STRESS_LEN_MAX];
uint16_t len = STRESS_LEN_MIN + (sys_rand32_get() % STRESS_LEN_MOD); uint16_t len = STRESS_LEN_MIN + (sys_rand8_get() % STRESS_LEN_MOD);
int rpt = (sys_rand32_get() & 1) + 1; int rpt = (sys_rand8_get() & 1) + 1;
zassert_true(len < sizeof(buf)); zassert_true(len < sizeof(buf));

View file

@ -116,7 +116,7 @@ static bool context_handler(void *user_data, uint32_t cnt, bool last, int prio)
uint32_t i = cnt | (prio << CNT_BITS); uint32_t i = cnt | (prio << CNT_BITS);
switch (sys_rand32_get() % 4) { switch (sys_rand8_get() % 4) {
case 0: case 0:
LOG_INF("%u", i); LOG_INF("%u", i);
break; break;