net: tests: Use lighter printk() instead of printf()
Use printk(), snprintk() instead of printf() and snprintf(). CONFIG_STDOUT_CONSOLE is anyway disabled by default so printf() will not output anything without it. Change-Id: I5899741df2e187dae7b4602d074e9b4cbb9952aa Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
parent
5cf134f45a
commit
538d8d4032
3 changed files with 15 additions and 19 deletions
|
@ -14,11 +14,9 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <misc/printk.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_ip.h>
|
||||
|
@ -107,7 +105,7 @@ static int tester_send(struct net_if *iface, struct net_buf *buf)
|
|||
if (!req_test && memcmp(&hdr->dst, &hwaddr,
|
||||
sizeof(struct net_eth_addr))) {
|
||||
char out[sizeof("xx:xx:xx:xx:xx:xx")];
|
||||
snprintf(out, sizeof(out),
|
||||
snprintk(out, sizeof(out), "%s",
|
||||
net_sprint_ll_addr(
|
||||
(uint8_t *)&hdr->dst,
|
||||
sizeof(struct net_eth_addr)));
|
||||
|
@ -124,7 +122,7 @@ static int tester_send(struct net_if *iface, struct net_buf *buf)
|
|||
if (memcmp(&hdr->src, &hwaddr,
|
||||
sizeof(struct net_eth_addr))) {
|
||||
char out[sizeof("xx:xx:xx:xx:xx:xx")];
|
||||
snprintf(out, sizeof(out),
|
||||
snprintk(out, sizeof(out), "%s",
|
||||
net_sprint_ll_addr(
|
||||
(uint8_t *)&hdr->src,
|
||||
sizeof(struct net_eth_addr)));
|
||||
|
@ -464,7 +462,7 @@ static bool run_tests(void)
|
|||
if (!net_ipv4_addr_cmp(&arp_hdr->dst_ipaddr,
|
||||
&NET_IPV4_BUF(buf)->dst)) {
|
||||
char out[sizeof("xxx.xxx.xxx.xxx")];
|
||||
snprintf(out, sizeof(out),
|
||||
snprintk(out, sizeof(out), "%s",
|
||||
net_sprint_ipv4_addr(&arp_hdr->dst_ipaddr));
|
||||
printk("ARP IP dest invalid %s, should be %s", out,
|
||||
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->dst));
|
||||
|
@ -474,7 +472,7 @@ static bool run_tests(void)
|
|||
if (!net_ipv4_addr_cmp(&arp_hdr->src_ipaddr,
|
||||
&NET_IPV4_BUF(buf)->src)) {
|
||||
char out[sizeof("xxx.xxx.xxx.xxx")];
|
||||
snprintf(out, sizeof(out),
|
||||
snprintk(out, sizeof(out), "%s",
|
||||
net_sprint_ipv4_addr(&arp_hdr->src_ipaddr));
|
||||
printk("ARP IP src invalid %s, should be %s", out,
|
||||
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->src));
|
||||
|
@ -510,7 +508,7 @@ static bool run_tests(void)
|
|||
|
||||
if (!net_ipv4_addr_cmp(&arp_hdr->dst_ipaddr, &iface->ipv4.gw)) {
|
||||
char out[sizeof("xxx.xxx.xxx.xxx")];
|
||||
snprintf(out, sizeof(out),
|
||||
snprintk(out, sizeof(out), "%s",
|
||||
net_sprint_ipv4_addr(&arp_hdr->dst_ipaddr));
|
||||
printk("ARP IP dst invalid %s, should be %s\n", out,
|
||||
net_sprint_ipv4_addr(&iface->ipv4.gw));
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <misc/printk.h>
|
||||
#include <sections.h>
|
||||
|
||||
#include <tc_util.h>
|
||||
|
@ -70,10 +68,11 @@
|
|||
uint8_t ll1[] = { a, b, c, d, e, f }; \
|
||||
uint8_t ll2[] = { f, e, d, c, b, a }; \
|
||||
char out[2 * sizeof("xx:xx:xx:xx:xx:xx") + 1 + 1]; \
|
||||
sprintf(out, "%s ", \
|
||||
net_sprint_ll_addr(ll1, sizeof(ll1))); \
|
||||
sprintf(out + sizeof("xx:xx:xx:xx:xx:xx"), "%s", \
|
||||
net_sprint_ll_addr(ll2, sizeof(ll2))); \
|
||||
snprintk(out, sizeof(out), "%s ", \
|
||||
net_sprint_ll_addr(ll1, sizeof(ll1))); \
|
||||
snprintk(out + sizeof("xx:xx:xx:xx:xx:xx"), \
|
||||
sizeof(out), "%s", \
|
||||
net_sprint_ll_addr(ll2, sizeof(ll2))); \
|
||||
if (strcmp(out, expected)) { \
|
||||
printk("Test %s failed, got %s\n", expected, out); \
|
||||
return false; \
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <misc/printk.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <tc_util.h>
|
||||
|
||||
|
@ -285,23 +284,23 @@ static void hexdump(const char *str, const uint8_t *packet, size_t length)
|
|||
|
||||
while (length--) {
|
||||
if (n % 16 == 0) {
|
||||
printf("%s %08X ", str, n);
|
||||
printk("%s %08X ", str, n);
|
||||
}
|
||||
|
||||
printf("%02X ", *packet++);
|
||||
printk("%02X ", *packet++);
|
||||
|
||||
n++;
|
||||
if (n % 8 == 0) {
|
||||
if (n % 16 == 0) {
|
||||
printf("\n");
|
||||
printk("\n");
|
||||
} else {
|
||||
printf(" ");
|
||||
printk(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n % 16) {
|
||||
printf("\n");
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue