2 * Copyright (c) 2012, The Chromium Authors
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <display_options.h>
13 #define FAKE_BUILD_TAG "jenkins-u-boot-denx_uboot_dm-master-build-aarch64" \
14 "and a lot more text to come"
16 static int do_ut_print(cmd_tbl_t *cmdtp, int flag, int argc,
24 printf("%s: Testing print\n", __func__);
26 snprintf(str, sizeof(str), "testing");
27 assert(!strcmp("testing", str));
29 snprintf(str, sizeof(str), "testing but too long");
30 assert(!strcmp("testing b", str));
32 snprintf(str, 1, "testing none");
33 assert(!strcmp("", str));
36 snprintf(str, 0, "testing none");
39 sprintf(big_str, "_%ls_", L"foo");
40 assert(!strcmp("_foo_", big_str));
42 /* Test the banner function */
43 s = display_options_get_banner(true, str, sizeof(str));
45 assert(!strcmp("\n\nU-Boo\n\n", s));
47 s = display_options_get_banner(true, str, 1);
49 assert(!strcmp("", s));
51 s = display_options_get_banner(true, str, 2);
53 assert(!strcmp("\n", s));
55 s = display_options_get_banner(false, str, sizeof(str));
57 assert(!strcmp("U-Boot \n\n", s));
59 /* Give it enough space for some of the version */
60 big_str_len = strlen(version_string) - 5;
61 s = display_options_get_banner_priv(false, FAKE_BUILD_TAG, big_str,
64 assert(!strncmp(version_string, s, big_str_len - 3));
65 assert(!strcmp("\n\n", s + big_str_len - 3));
67 /* Give it enough space for the version and some of the build tag */
68 big_str_len = strlen(version_string) + 9 + 20;
69 s = display_options_get_banner_priv(false, FAKE_BUILD_TAG, big_str,
72 len = strlen(version_string);
73 assert(!strncmp(version_string, s, len));
74 assert(!strncmp(", Build: ", s + len, 9));
75 assert(!strncmp(FAKE_BUILD_TAG, s + 9 + len, 12));
76 assert(!strcmp("\n\n", s + big_str_len - 3));
78 printf("%s: Everything went swimmingly\n", __func__);
83 ut_print, 1, 1, do_ut_print,
84 "Very basic test of printf(), etc.",