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 /* Test the banner function */
40 s = display_options_get_banner(true, str, sizeof(str));
42 assert(!strcmp("\n\nU-Boo\n\n", s));
44 s = display_options_get_banner(true, str, 1);
46 assert(!strcmp("", s));
48 s = display_options_get_banner(true, str, 2);
50 assert(!strcmp("\n", s));
52 s = display_options_get_banner(false, str, sizeof(str));
54 assert(!strcmp("U-Boot \n\n", s));
56 /* Give it enough space for some of the version */
57 big_str_len = strlen(version_string) - 5;
58 s = display_options_get_banner_priv(false, FAKE_BUILD_TAG, big_str,
61 assert(!strncmp(version_string, s, big_str_len - 3));
62 assert(!strcmp("\n\n", s + big_str_len - 3));
64 /* Give it enough space for the version and some of the build tag */
65 big_str_len = strlen(version_string) + 9 + 20;
66 s = display_options_get_banner_priv(false, FAKE_BUILD_TAG, big_str,
69 len = strlen(version_string);
70 assert(!strncmp(version_string, s, len));
71 assert(!strncmp(", Build: ", s + len, 9));
72 assert(!strncmp(FAKE_BUILD_TAG, s + 9 + len, 12));
73 assert(!strcmp("\n\n", s + big_str_len - 3));
75 printf("%s: Everything went swimmingly\n", __func__);
80 ut_print, 1, 1, do_ut_print,
81 "Very basic test of printf(), etc.",