Skip to content

Commit 0d3fd46

Browse files
authored
Merge pull request #1 from avinaw01-arm/main
VAL Infrastructure Optimizations Release
2 parents 89c0a83 + 2dcef66 commit 0d3fd46

5 files changed

Lines changed: 45 additions & 23 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
This Common VAL repository consolidates shared functionalities across the FF-A, RMM, and PSA-M ACS projects. This centralized approach ensures consistent implementation while eliminating redundant efforts among stakeholders. Key functionalities include Logging, Status reporting, Regression report, etc.
55

6+
7+
## License
8+
9+
Arm Common VAl ACS is distributed under BSD-3-Clause License.
10+
611
--------------
712

813
*Copyright (c) 2024-2025, Arm Limited or its affiliates. All rights reserved.*

inc/val_common_framework.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ void val_handle_reboot_result(uint32_t test_progress);
3535
void val_update_regression_report(uint32_t test_result, regre_report_t *regre_report);
3636
void val_print_regression_report(regre_report_t *regre_report);
3737

38+
void val_mem_copy(char *dest, const char *src, size_t len);
39+
3840
#endif /* VAL_COMMON_FRAMEWORK_H */

src/val_common_framework.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,16 @@ void val_print_regression_report(regre_report_t *regre_report)
166166
val_printf(ALWAYS, "******* END OF ACS *******\n");
167167
val_printf(ALWAYS, "\n");
168168
}
169+
170+
/**
171+
* @brief - Copies 'len' bytes from source to destination buffer
172+
* @param - dest : Destination buffer
173+
* - src : Source buffer
174+
* - len : Number of bytes to copy
175+
* @return - void
176+
*/
177+
void val_mem_copy(char *dest, const char *src, size_t len)
178+
{
179+
for (size_t i = 0; i < len; ++i)
180+
dest[i] = src[i];
181+
}

src/val_common_log.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "val_common_log.h"
9+
#include "val_common_framework.h"
910

1011
static void val_putc(char *c)
1112
{
@@ -587,16 +588,17 @@ static size_t val_log(const char *fmt, va_list args)
587588
uint32_t val_printf(print_verbosity_t verbosity, const char *msg, ...)
588589
{
589590
size_t chars_written = 0;
590-
va_list args;
591+
size_t len = log_strnlen_s(msg, LOG_MAX_STRING_LENGTH - 2);
591592
static bool lastWasNewline = true;
593+
char formatted_msg[LOG_MAX_STRING_LENGTH];
594+
va_list args;
592595

593596
va_start(args, msg);
597+
594598
if (verbosity >= VERBOSITY)
595599
{
596-
597600
if (lastWasNewline)
598601
{
599-
val_putc("\r");
600602
switch (verbosity)
601603
{
602604
case INFO:
@@ -612,33 +614,39 @@ uint32_t val_printf(print_verbosity_t verbosity, const char *msg, ...)
612614
break;
613615

614616
case WARN:
615-
print_raw_string("\tWARN: ");
617+
print_raw_string("\t\tWARN: ");
616618
break;
617619

618620
case ERROR:
619-
print_raw_string("\tERROR: ");
621+
print_raw_string("\t\tERROR: ");
620622
break;
621623

622624
case ALWAYS:
623-
print_raw_string("\t");
625+
print_raw_string("");
624626
break;
625627

626628
default:
627-
chars_written = val_log(msg, args);
628-
return (uint32_t)chars_written;
629629
break;
630630
}
631631
}
632-
chars_written = val_log(msg, args);
633632

634-
size_t len = log_strnlen_s(msg, LOG_MAX_STRING_LENGTH);
635633
if (len > 0 && msg[len - 1] == '\n')
634+
{
635+
val_mem_copy(formatted_msg, msg, len - 1);
636+
formatted_msg[len - 1] = '\r';
637+
formatted_msg[len] = '\n';
638+
formatted_msg[len + 1] = '\0';
639+
640+
chars_written = val_log(formatted_msg, args);
636641
lastWasNewline = true;
642+
}
637643
else
644+
{
645+
chars_written = val_log(msg, args);
638646
lastWasNewline = false;
639-
640-
va_end(args);
647+
}
641648
}
649+
va_end(args);
642650

643651
return (uint32_t)chars_written;
644652
}

src/val_common_status.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
#include "val_common_status.h"
99
#include "val_common_log.h"
1010

11-
#ifndef PLATFORM_SHARED_REGION_BASE
12-
val_test_status_buffer_ts g_status_buffer;
13-
#define PLATFORM_SHARED_REGION_BASE (&g_status_buffer)
14-
#endif
15-
1611
static uint64_t width;
1712

1813
/**
@@ -94,34 +89,33 @@ uint32_t val_report_status(void)
9489
{
9590
case TEST_PASS:
9691
state = TEST_PASS;
97-
val_printf(ALWAYS, "\nResult => Passed\n");
92+
val_printf(ALWAYS, "Result=Passed\n");
9893
break;
9994

10095
case TEST_FAIL:
10196
state = TEST_FAIL;
102-
val_printf(ALWAYS, "\nResult => Failed (Error code=%d)\n",
97+
val_printf(ALWAYS, "Result=Failed (Error code=%d)\n",
10398
status_code);
10499
break;
105100

106101
case TEST_SKIP:
107102
state = TEST_SKIP;
108-
val_printf(ALWAYS, "\nResult => Skipped (Skip code=%d)\n",
103+
val_printf(ALWAYS, "Result=Skipped (Skip code=%d)\n",
109104
status_code);
110105
break;
111106

112107
case TEST_ERROR:
113108
state = TEST_ERROR;
114-
val_printf(ALWAYS, "\nResult => Error (Error code=%d)\n",
109+
val_printf(ALWAYS, "Result=Error (Error code=%d)\n",
115110
status_code);
116111
break;
117112
default:
118113
state = TEST_FAIL;
119-
val_printf(ALWAYS, "\nResult => Failed (Error Code=%d)\n",
114+
val_printf(ALWAYS, "Result=Failed (Error Code=%d)\n",
120115
status_code);
121116
break;
122117
}
123118

124-
val_printf(ALWAYS, "\n");
125119
val_printf(ALWAYS, "***********************************\n");
126120
return state;
127121
}

0 commit comments

Comments
 (0)