Skip to content

Commit

Permalink
xtest: regression 1006: test empty binary block properties
Browse files Browse the repository at this point in the history
Add tests of empty binary block properties in os_test TA, exercised
by xtest regression test 1006.

Signed-off-by: Etienne Carriere <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
  • Loading branch information
etienne-lms authored and jforissier committed May 29, 2020
1 parent b34caff commit 3ef6bf9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
8 changes: 7 additions & 1 deletion ta/os_test/include/user_ta_header_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@
{ "myprop.binaryblock.3byte-ones", USER_TA_PROP_TYPE_BINARY_BLOCK, \
"////" }, \
{ "myprop.binaryblock.4byte-ones", USER_TA_PROP_TYPE_BINARY_BLOCK, \
"/////w==" },
"/////w==" }, \
{ "myprop.binaryblock.empty1", USER_TA_PROP_TYPE_BINARY_BLOCK, \
"" }, \
{ "myprop.binaryblock.empty2", USER_TA_PROP_TYPE_BINARY_BLOCK, \
"====" }, \
{ "myprop.binaryblock.empty3", USER_TA_PROP_TYPE_BINARY_BLOCK, \
"-%@&" /* Only invalid code */},
#endif
26 changes: 20 additions & 6 deletions ta/os_test/os_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,15 @@ while (true) {
}

/* Get the property with a very small buffer */
vblen2 = 1;
res = TEE_GetPropertyAsString(prop_set, nbuf, vbuf2, &vblen2);
res = check_returned_prop(__LINE__, nbuf, res, TEE_ERROR_SHORT_BUFFER,
vblen2, vblen);
if (res != TEE_SUCCESS)
return res;
if (vblen > 1) {
vblen2 = 1;
res = TEE_GetPropertyAsString(prop_set, nbuf, vbuf2, &vblen2);
res = check_returned_prop(__LINE__, nbuf, res,
TEE_ERROR_SHORT_BUFFER,
vblen2, vblen);
if (res != TEE_SUCCESS)
return res;
}

/* Get the property with almost the correct buffer */
vblen2 = vblen - 1;
Expand Down Expand Up @@ -319,6 +322,14 @@ while (true) {
res = check_binprop_ones(4, bbuf, bblen);
if (res)
return res;
} else if (!strcmp("myprop.binaryblock.empty1", nbuf) ||
!strcmp("myprop.binaryblock.empty2", nbuf) ||
!strcmp("myprop.binaryblock.empty3", nbuf)) {
if (bblen) {
EMSG("Property \"%s\": %zu byte(s)",
nbuf, bblen);
return TEE_ERROR_GENERIC;
}
} else {
EMSG("Unexpected property \"%s\"", nbuf);
TEE_Panic(0);
Expand Down Expand Up @@ -395,6 +406,9 @@ static TEE_Result test_properties(void)
{"myprop.binaryblock.2byte-ones", P_TYPE_BINARY_BLOCK},
{"myprop.binaryblock.3byte-ones", P_TYPE_BINARY_BLOCK},
{"myprop.binaryblock.4byte-ones", P_TYPE_BINARY_BLOCK},
{"myprop.binaryblock.empty1", P_TYPE_BINARY_BLOCK},
{"myprop.binaryblock.empty2", P_TYPE_BINARY_BLOCK},
{"myprop.binaryblock.empty3", P_TYPE_BINARY_BLOCK},
};
const size_t num_p_attrs = sizeof(p_attrs) / sizeof(p_attrs[0]);
size_t n = 0;
Expand Down

0 comments on commit 3ef6bf9

Please sign in to comment.