halcc: Fix manifest scheme 81/311181/3
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 14 May 2024 11:27:02 +0000 (20:27 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 17 May 2024 05:40:51 +0000 (14:40 +0900)
Attribute "version" has changed to "platform-version" and attribute
"type" has been removed.
 As-is: <manifest version="1.0" type="platform">
 To-be: <manifest platform-version="9.0">

Change-Id: I296c0b119913d117d1b453e5947ed71c50d76946
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
src/common.h
src/hal-api-compatibility-checker-object.c
src/hal-api-compatibility-checker-object.h
src/hal-api-compatibility-checker-parser.c
src/hal-api-compatibility-checker-util.c [deleted file]
src/hal-api-compatibility-checker-util.h [deleted file]
src/hal-api-compatibility-checker.c
tests/unittest/test-hal-compatibility-checker.cc

index cdcc1b7cb1afe09116f4a726a4e67b17bb0aeb16..e55c0d210b1fcf44ee3c3334ac048fb6dcf18a21 100644 (file)
@@ -47,8 +47,7 @@ SET(SRCS
        src/hal-api-conf.c
        src/hal-api-compatibility-checker.c
        src/hal-api-compatibility-checker-object.c
-       src/hal-api-compatibility-checker-parser.c
-       src/hal-api-compatibility-checker-util.c)
+       src/hal-api-compatibility-checker-parser.c)
 
 ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS})
 TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -Wl,-z,nodelete,--no-undefined)
index 8d30e8b33ce4132361b64dde759e5d1c14aa8450..03b25647ce1c65114a097cbbcda18bf954644d47 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
 #endif
 
 #define ARRAY_SIZE(name)       (sizeof(name)/sizeof(name[0]))
+#define HALCC_NAME_MAX                 128
 
 enum hal_license {
        HAL_LICENSE_UNKNOWN = 0,
index 0b48e2970e52c4bd07fc7f51a4aa8aa6daa33832..5d076dd390f0e23884776b2639db596d2ec468b6 100644 (file)
@@ -24,9 +24,9 @@
 #include <errno.h>
 #include <glib.h>
 
+#include "common.h"
 #include "hal-api-compatibility-checker-object.h"
 #include "hal-api-compatibility-checker-parser.h"
-#include "hal-api-compatibility-checker-util.h"
 
 #define HALCC_TRANSPORT_DEFAULT                HALCC_TRANSPORT_PASSTHROUGH
 #define MAX_NUM_VERSION                        8
@@ -51,8 +51,7 @@ typedef struct halcc_hal {
 } halcc_hal;
 
 typedef struct halcc_manifest {
-       halcc_manifest_type_e manifest_type;
-       halcc_version version;
+       halcc_version platform_version;
        GHashTable *hals;
 } halcc_manifest;
 
@@ -221,9 +220,8 @@ int halcc_manifest_new(halcc_manifest **manifest)
        }
 
        *m = (halcc_manifest) {
-               .manifest_type = HALCC_UNINITIALIZED_INT,
-               .version.major = HALCC_UNINITIALIZED_INT,
-               .version.minor = HALCC_UNINITIALIZED_INT,
+               .platform_version.major = 0,
+               .platform_version.minor = 0,
                .hals = hashtable_hal_new(),
        };
 
@@ -244,38 +242,8 @@ void halcc_manifest_free(halcc_manifest *manifest)
        free(manifest);
 }
 
-int halcc_manifest_set_type(halcc_manifest *manifest, halcc_manifest_type_e type)
-{
-       if (!manifest) {
-               printf("Invalid parameter\n");
-               return -EINVAL;
-       }
-
-       if (type < HALCC_MANIFEST_TYPE_HAL_API || type > HALCC_MANIFEST_TYPE_HAL_BACKEND) {
-               printf("Invalid parameter of type=%d\n", type);
-               return -EINVAL;
-       }
-
-
-       return halcc_util_set_int_once(&manifest->manifest_type, type, "manifest.type");
-}
-
-int halcc_manifest_get_type(halcc_manifest *manifest, halcc_manifest_type_e *type)
+int halcc_manifest_set_platform_version(halcc_manifest *manifest, int major, int minor)
 {
-       if (!manifest || !type) {
-               printf("Invalid parameter\n");
-               return -EINVAL;
-       }
-
-       *type = manifest->manifest_type;
-
-       return 0;
-}
-
-int halcc_manifest_set_version(halcc_manifest *manifest, int major, int minor)
-{
-       int ret;
-
        if (!manifest) {
                printf("Invalid parameter\n");
                return -EINVAL;
@@ -286,30 +254,21 @@ int halcc_manifest_set_version(halcc_manifest *manifest, int major, int minor)
                return -EINVAL;
        }
 
-       ret = halcc_util_set_int_once(&manifest->version.major, major, "manifest.version.major");
-       if (ret != 0) {
-               printf("Failed to set major version=%d\n", major);
-               return ret;
-       }
-
-       ret = halcc_util_set_int_once(&manifest->version.minor, minor, "manifest.version.minor");
-       if (ret != 0) {
-               printf("Failed to set minor version=%d\n", minor);
-               return ret;
-       }
+       manifest->platform_version.major = major;
+       manifest->platform_version.minor = minor;
 
        return 0;
 }
 
-int halcc_manifest_get_version(halcc_manifest *manifest, int *major, int *minor)
+int halcc_manifest_get_platform_version(halcc_manifest *manifest, int *major, int *minor)
 {
        if (!manifest || !major || !minor) {
                printf("Invalid parameter\n");
                return -EINVAL;
        }
 
-       *major = manifest->version.major;
-       *minor = manifest->version.minor;
+       *major = manifest->platform_version.major;
+       *minor = manifest->platform_version.minor;
 
        return 0;
 }
index 80d568c6e48d9fb958670635830a20ca5143eef3..e5885258d5f2a0a0a2a4ddc5957d81369da8fe79 100644 (file)
@@ -44,10 +44,8 @@ typedef void (*halcc_iter_cb) (void *, void *);
 
 int halcc_manifest_new(halcc_manifest **manifest);
 void halcc_manifest_free(halcc_manifest *manifest);
-int halcc_manifest_set_type(halcc_manifest *manifest, halcc_manifest_type_e type);
-int halcc_manifest_get_type(halcc_manifest *manifest, halcc_manifest_type_e *type);
-int halcc_manifest_set_version(halcc_manifest *manifest, int major, int minor);
-int halcc_manifest_get_version(halcc_manifest *manifest, int *major, int *minor);
+int halcc_manifest_set_platform_version(halcc_manifest *manifest, int major, int minor);
+int halcc_manifest_get_platform_version(halcc_manifest *manifest, int *major, int *minor);
 int halcc_manifest_add_hal(halcc_manifest *manifest, halcc_hal *hal);
 int halcc_manifest_find_hal(halcc_manifest *manifest, const char *hal_name, halcc_hal **hal);
 void halcc_manifest_remove_hal(halcc_manifest *manifest, const char *hal_name);
index 50b8bb16a5d939ff8254da337f951219fa03a39e..c2fcd866cf2f449ba8bc821289a92d31b3bb1670 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "hal-api-compatibility-checker-object.h"
 #include "hal-api-compatibility-checker-parser.h"
-#include "hal-api-compatibility-checker-util.h"
 
 #define HALCC_DESERIALIZER_VERSION_MAJOR               1
 #define HALCC_DESERIALIZER_VERSION_MINOR               0
@@ -170,9 +169,9 @@ static int parse_manifest(xmlNode *node, halcc_manifest *manifest)
        }
 
        // version
-       prop = xmlGetProp(node, "version");
+       prop = xmlGetProp(node, "platform-version");
        if (!prop) {
-               printf("Failed to xmlGetProp() \"version\"\n");
+               printf("Failed to xmlGetProp() \"platform-version\"\n");
                return -EINVAL;
        }
 
@@ -180,47 +179,16 @@ static int parse_manifest(xmlNode *node, halcc_manifest *manifest)
        xmlFree(prop);
 
        if (ret != 2) {
-               printf("Failed to scan version, ret=%d\n", ret);
+               printf("Failed to scan platform-version, ret=%d\n", ret);
                return -EINVAL;
        }
 
-       if (major != HALCC_DESERIALIZER_VERSION_MAJOR || minor != HALCC_DESERIALIZER_VERSION_MINOR) {
-               printf("Manifest scheme doesn't match. Requires manifest version %d.%d\n",
-                       HALCC_DESERIALIZER_VERSION_MAJOR, HALCC_DESERIALIZER_VERSION_MINOR);
-               return -ENOTSUP;
-       }
-
-       ret = halcc_manifest_set_version(manifest, major, minor);
+       ret = halcc_manifest_set_platform_version(manifest, major, minor);
        if (ret != 0) {
                printf("Failed to halcc_manifest_set_version(), ret=%d\n", ret);
                return -EINVAL;
        }
 
-       // type
-       prop = xmlGetProp(node, "type");
-       if (!prop) {
-               printf("Failed to xmlGetProp() \"type\"\n");
-               return -EINVAL;
-       }
-
-       if (xmlStrEqual(prop, "platform")) {
-               ret = halcc_manifest_set_type(manifest, HALCC_MANIFEST_TYPE_HAL_API);
-               if (ret != 0)
-                       printf("Failed to halcc_manifest_set_type() HALCC_MANIFEST_TYPE_HAL_API, ret=%d\n", ret);
-       } else if (xmlStrEqual(prop, "device")) {
-               ret = halcc_manifest_set_type(manifest, HALCC_MANIFEST_TYPE_HAL_BACKEND);
-               if (ret != 0)
-                       printf("Failed to halcc_manifest_set_type() HALCC_MANIFEST_TYPE_HAL_BACKEND, ret=%d\n", ret);
-       } else {
-               printf("Invalid type property=%s\n", prop);
-               ret = -EINVAL;
-       }
-
-       xmlFree(prop);
-
-       if (ret != 0)
-               return ret;
-
        for (xmlNode *child = node->children; child; child = child->next) {
                int ret;
 
diff --git a/src/hal-api-compatibility-checker-util.c b/src/hal-api-compatibility-checker-util.c
deleted file mode 100644 (file)
index 7a7b97b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <errno.h>
-
-#include "hal-api-compatibility-checker-util.h"
-
-int halcc_util_set_int_once(void *buf, int value, const char *buf_desc)
-{
-       int old_value;
-
-       if (!buf)
-               return -EINVAL;
-
-       old_value = *(int *) buf;
-
-       if (old_value != HALCC_UNINITIALIZED_INT && old_value != value) {
-               printf("Cannot modify initialized value, %s, %d to %d\n",
-                       buf_desc ? : "Unknown", old_value, value);
-               return -EALREADY;
-       }
-
-       *(int *) buf = value;
-
-       return 0;
-}
diff --git a/src/hal-api-compatibility-checker-util.h b/src/hal-api-compatibility-checker-util.h
deleted file mode 100644 (file)
index 7cc9f50..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HAL_API_COMPATIBILITY_CHECKER_UTIL_H__
-#define __HAL_API_COMPATIBILITY_CHECKER_UTIL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define HALCC_NAME_MAX                 128
-#define HALCC_UNINITIALIZED_INT                (-1)
-
-/**
- * Modifies buffer pointed by 'buf' to 'value' only when the buffer
- * has value of HALCC_UNINITIALIZED_INT. Once it has changed to value other
- * than HALCC_UNINITIALIZED_INT and trying to change the value, the buffer
- * remains unchanged and this function returns -EALREADY.
- */
-int halcc_util_set_int_once(void *buf, int value, const char *buf_desc);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __HAL_API_COMPATIBILITY_CHECKER_UTIL_H__
index 56fce9487fbd39604b70454201d1d1d8475ef628..e7b6fe52bca6be1270f0689055e0dd9a89c52370 100644 (file)
@@ -34,7 +34,6 @@
 #include "hal-api-compatibility-checker.h"
 #include "hal-api-compatibility-checker-object.h"
 #include "hal-api-compatibility-checker-parser.h"
-#include "hal-api-compatibility-checker-util.h"
 
 #define HAL_CC_DEFAULT_HAL_INFO_INI_PATH               "/hal/etc/hal-info.ini"
 #define HAL_CC_DEFAULT_HAL_MANIFEST_DIR                        "/etc/hal-manifest"
index 65f5de9bf522dc5417e0da49f947c6ff813385b3..e0fb310cdcb391343e90cb0ee484a3c5f9dfc492 100644 (file)
@@ -25,7 +25,7 @@ using namespace std;
 
 static char g_manifest_xml[] =
 "<root>"
-"      <manifest version=\"1.0\" type=\"platform\">"
+"      <manifest platform-version=\"9.0\">"
 "              <hal>"
 "                      <name>hal.device.display</name>"
 "                      <version>1.5</version>"
@@ -51,13 +51,13 @@ static char g_manifest_xml[] =
 "                      </interface>"
 "              </hal>"
 "      </manifest>"
-"      <manifest version=\"1.0\" type=\"platform\">"
+"      <manifest platform-version=\"10.0\">"
 "              <hal>"
 "                      <name>HAL_MODULE_BAR</name>"
 "                      <version>2.0</version>"
 "              </hal>"
 "      </manifest>"
-"      <manifest version=\"1.0\" type=\"platform\">"
+"      <manifest platform-version=\"1.0\">"
 "              <hal>"
 "                      <name>HAL_MODULE_BAR</name>"
 "                      <version>2.2</version>"
@@ -108,27 +108,6 @@ halcc_manifest* HalccObjectTest::g_manifest = NULL;
 halcc_hal* HalccObjectTest::g_hal = NULL;
 halcc_interface* HalccObjectTest::g_interface = NULL;
 
-TEST_F(HalccObjectTest, manifest_get_type)
-{
-       halcc_manifest_type_e type;
-       int ret;
-
-       ret = halcc_manifest_get_type(g_manifest, &type);
-       ASSERT_EQ(ret, 0);
-       ASSERT_EQ(type, HALCC_MANIFEST_TYPE_HAL_API);
-}
-
-TEST_F(HalccObjectTest, manifest_get_version)
-{
-       int major, minor;
-       int ret;
-
-       ret = halcc_manifest_get_version(g_manifest, &major, &minor);
-       ASSERT_EQ(ret, 0);
-       ASSERT_EQ(major, 1);
-       ASSERT_EQ(minor, 0);
-}
-
 TEST_F(HalccObjectTest, manifest_find_hal_success)
 {
        halcc_hal *hal = NULL;