hashtable_foreach(hal->interfaces, cb, user_data);
}
+bool halcc_hal_is_compatible_with_version(halcc_hal *hal, int major, int minor)
+{
+ if (!hal) {
+ printf("Invalid parameter\n");
+ return false;
+ }
+
+ for (int i = 0; i < hal->num_version; ++i) {
+ if (hal->version_list[i].major != major) {
+ printf("Major not matched\n");
+ continue;
+ }
+
+ if (hal->version_list[i].minor < minor) {
+ printf("Minor not supported\n");
+ continue;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
int halcc_interface_new(halcc_interface **interface)
{
halcc_interface *iface;
protected:
static void SetUpTestSuite() {
int ret;
+ bool compatibility;
ret = halcc_manifest_new(&g_manifest);
ASSERT_EQ(ret, 0);
ret = halcc_parse_string(g_manifest_xml, strlen(g_manifest_xml), g_manifest);
ASSERT_EQ(ret, 0);
- ret = halcc_manifest_find_hal(g_manifest, "hal.test", 4, 8, &g_hal);
+ ret = halcc_manifest_find_hal_by_name(g_manifest, "hal.test", &g_hal);
ASSERT_EQ(ret, 0);
+
+ compatibility = halcc_hal_is_compatible_with_version(g_hal, 4, 8);
+ ASSERT_EQ(compatibility, true);
}
static void TearDownTestSuite() {
{
halcc_hal *hal = NULL;
int ret;
+ bool compatibility;
- ret = halcc_manifest_find_hal(g_manifest, "hal.device.display", 1, 5, &hal);
+ ret = halcc_manifest_find_hal_by_name(g_manifest, "hal.device.display", &hal);
ASSERT_EQ(ret, 0);
+
+ compatibility = halcc_hal_is_compatible_with_version(hal, 1, 5);
+ ASSERT_EQ(compatibility, true);
}
TEST_F(HalccObjectTest, manifest_find_hal_fail)
{
halcc_hal *hal = NULL;
int ret;
+ bool compatibility;
- ret = halcc_manifest_find_hal(g_manifest, "hal.device.display", 1, 4, &hal);
- ASSERT_EQ(ret, -ENOTSUP);
+ ret = halcc_manifest_find_hal_by_name(g_manifest, "hal.device.display", &hal);
+ ASSERT_EQ(ret, 0);
- ret = halcc_manifest_find_hal(g_manifest, "hal.device.display", 1, 6, &hal);
- ASSERT_EQ(ret, -ENOTSUP);
+ compatibility = halcc_hal_is_compatible_with_version(hal, 1, 4);
+ ASSERT_EQ(compatibility, true);
- ret = halcc_manifest_find_hal(g_manifest, "hal.device.display", 2, 4, &hal);
- ASSERT_EQ(ret, -ENOTSUP);
+ compatibility = halcc_hal_is_compatible_with_version(hal, 1, 6);
+ ASSERT_EQ(compatibility, false);
+
+ compatibility = halcc_hal_is_compatible_with_version(hal, 2, 4);
+ ASSERT_EQ(compatibility, false);
}
TEST_F(HalccObjectTest, manifest_find_hal_backward_compatible_success)