test_printf.c (e700ac213a0f793fb4f83098413303e3dd080892) test_printf.c (c666d447e091be3a742588b49290e7733115769f)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Test cases for printf facility.
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/init.h>

--- 572 unchanged lines hidden (view full) ---

581netdev_features(void)
582{
583}
584
585struct page_flags_test {
586 int width;
587 int shift;
588 int mask;
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Test cases for printf facility.
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/init.h>

--- 572 unchanged lines hidden (view full) ---

581netdev_features(void)
582{
583}
584
585struct page_flags_test {
586 int width;
587 int shift;
588 int mask;
589 unsigned long value;
590 const char *fmt;
591 const char *name;
592};
593
589 const char *fmt;
590 const char *name;
591};
592
594static struct page_flags_test pft[] = {
593static const struct page_flags_test pft[] = {
595 {SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK,
594 {SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK,
596 0, "%d", "section"},
595 "%d", "section"},
597 {NODES_WIDTH, NODES_PGSHIFT, NODES_MASK,
596 {NODES_WIDTH, NODES_PGSHIFT, NODES_MASK,
598 0, "%d", "node"},
597 "%d", "node"},
599 {ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK,
598 {ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK,
600 0, "%d", "zone"},
599 "%d", "zone"},
601 {LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK,
600 {LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK,
602 0, "%#x", "lastcpupid"},
601 "%#x", "lastcpupid"},
603 {KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK,
602 {KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK,
604 0, "%#x", "kasantag"},
603 "%#x", "kasantag"},
605};
606
607static void __init
608page_flags_test(int section, int node, int zone, int last_cpupid,
609 int kasan_tag, int flags, const char *name, char *cmp_buf)
610{
611 unsigned long values[] = {section, node, zone, last_cpupid, kasan_tag};
612 unsigned long page_flags = 0;

--- 9 unchanged lines hidden (view full) ---

622#if SECTIONS_WIDTH || NODES_WIDTH || ZONES_WIDTH || \
623 LAST_CPUPID_WIDTH || KASAN_TAG_WIDTH
624 /* Other information also included in page flags */
625 snprintf(cmp_buf + size, BUF_SIZE - size, "|");
626 size = strlen(cmp_buf);
627#endif
628 }
629
604};
605
606static void __init
607page_flags_test(int section, int node, int zone, int last_cpupid,
608 int kasan_tag, int flags, const char *name, char *cmp_buf)
609{
610 unsigned long values[] = {section, node, zone, last_cpupid, kasan_tag};
611 unsigned long page_flags = 0;

--- 9 unchanged lines hidden (view full) ---

621#if SECTIONS_WIDTH || NODES_WIDTH || ZONES_WIDTH || \
622 LAST_CPUPID_WIDTH || KASAN_TAG_WIDTH
623 /* Other information also included in page flags */
624 snprintf(cmp_buf + size, BUF_SIZE - size, "|");
625 size = strlen(cmp_buf);
626#endif
627 }
628
630 /* Set the test value */
631 for (i = 0; i < ARRAY_SIZE(pft); i++)
632 pft[i].value = values[i];
633
634 for (i = 0; i < ARRAY_SIZE(pft); i++) {
635 if (!pft[i].width)
636 continue;
637
638 if (append) {
639 snprintf(cmp_buf + size, BUF_SIZE - size, "|");
640 size = strlen(cmp_buf);
641 }
642
629 for (i = 0; i < ARRAY_SIZE(pft); i++) {
630 if (!pft[i].width)
631 continue;
632
633 if (append) {
634 snprintf(cmp_buf + size, BUF_SIZE - size, "|");
635 size = strlen(cmp_buf);
636 }
637
643 page_flags |= (pft[i].value & pft[i].mask) << pft[i].shift;
638 page_flags |= (values[i] & pft[i].mask) << pft[i].shift;
644 snprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name);
645 size = strlen(cmp_buf);
646 snprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt,
639 snprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name);
640 size = strlen(cmp_buf);
641 snprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt,
647 pft[i].value & pft[i].mask);
642 values[i] & pft[i].mask);
648 size = strlen(cmp_buf);
649 append = true;
650 }
651
652 test(cmp_buf, "%pGp", &page_flags);
653}
654
655static void __init

--- 159 unchanged lines hidden ---
643 size = strlen(cmp_buf);
644 append = true;
645 }
646
647 test(cmp_buf, "%pGp", &page_flags);
648}
649
650static void __init

--- 159 unchanged lines hidden ---