add syscap define check.

Signed-off-by: yudechen <chenyude@huawei.com>
Change-Id: I64f6a9d25913672393fd7c059478a5b52ebbcc15
This commit is contained in:
yudechen
2022-08-16 17:53:33 +08:00
parent c7a979fa85
commit 787901d674
3 changed files with 50 additions and 2 deletions
+28 -1
View File
@@ -24,7 +24,34 @@ sources_platform_common = [
"./src/endian_internal.c",
]
ohos_executable("syscap_define_check_bin") {
include_dirs = [ "include" ]
sources = [ "./test/syscap_define_check.c" ]
if (is_mingw) {
defines += [ "_POSIX_" ]
}
subsystem_name = "developtools"
part_name = "syscap_codec"
}
build_ext_component("syscap_define_check") {
deps = [ ":syscap_define_check_bin(//build/toolchain/linux:clang_x64)" ]
exec_path = rebase_path(root_out_dir)
if (defined(ohos_lite)) {
cmd = "${exec_path}/clang_x64/syscap_define_check_bin"
} else {
cmd = "${exec_path}/clang_x64/developtools/syscap_codec/syscap_define_check_bin"
}
command = "chmod 777 $cmd"
command += " && $cmd"
}
ohos_executable("syscap_tool_bin") {
deps = [ ":syscap_define_check" ]
output_name = "syscap_tool"
install_enable = true
include_dirs = [ "src" ]
@@ -37,7 +64,7 @@ ohos_executable("syscap_tool_bin") {
sources = [ "./src/main.c" ]
sources += sources_platform_common
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
deps += [ "//third_party/bounds_checking_function:libsec_static" ]
if (defined(ohos_lite)) {
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
+1 -1
View File
@@ -161,7 +161,7 @@ bool EncodePrivateSyscap(char **output, int *outputLen)
return false;
}
int priLen = bufferLen - PCID_MAIN_BYTES - 1;
uint32_t priLen = bufferLen - PCID_MAIN_BYTES - 1;
if (priLen <= 0) {
*outputLen = 0;
return false;
+21
View File
@@ -0,0 +1,21 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "syscap_define.h"
int main()
{
size_t size = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
// printf("size = %lu\n", size);
int flag = 0;
for (int i = 0; i < size; i++) {
if (g_arraySyscap[i].num != i) {
printf("[Error]: %s -> num(%u) should be %d.\n", g_arraySyscap[i].str, g_arraySyscap[i].num, i);
flag++;
}
}
// if (flag == 0) return 0;
// else exit(1);
exit(1);
}