%manifest deviced.manifest
%license LICENSE.Apache-2.0
%{_bindir}/deviced-auto-test
-%config %{_sysconfdir}/deviced/auto-test.conf
%files plugin-profile-mobile
%manifest deviced.manifest
test.c
main.c
result.c
- config.c
battery.c
display.c
led.c
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
capi-system-device
+ capi-system-info
vconf
udev
hal-api-common
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${deviced_LDFLAGS} deviced-common-private)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-test.conf DESTINATION /etc/deviced)
+++ /dev/null
-[mobile]
-booting=1
-battery-monitor=0
-battery=1
-display=1
-led=1
-power=1
-proc=1
-extcon=1
-ir=1
-time=1
-udev=1
-touchscreen=1
-pmqos=1
-
-[wearable]
-booting=1
-battery-monitor=1
-battery=1
-display=1
-brightness=1
-led=0
-power=1
-proc=1
-extcon=1
-ir=0
-time=1
-udev=1
-touchscreen=1
-pmqos=1
-
-[tv]
-booting=0
-battery-monitor=0
-battery=0
-display=1
-led=0
-power=1
-proc=1
-extcon=1
-ir=0
-time=1
-udev=1
-touchscreen=0
-pmqos=0
-
-[common]
-booting=1
-battery-monitor=0
-battery=0
-display=1
-led=0
-power=1
-proc=1
-extcon=1
-ir=0
-time=1
-udev=1
-touchscreen=1
-pmqos=1
\ No newline at end of file
.init = battery_monitor_init,
.exit = battery_monitor_exit,
.unit = battery_monitor_unit,
+ .required_feature = "tizen.org/feature/battery",
};
TEST_OPS_REGISTER(&battery_monitor_test_ops)
.init = battery_init,
.exit = battery_exit,
.unit = battery_unit,
+ .required_feature = "tizen.org/feature/battery",
};
TEST_OPS_REGISTER(&battery_test_ops)
+++ /dev/null
-/*
- * deviced
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * 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 <glib.h>
-#include <string.h>
-
-#include <libsyscommon/ini-parser.h>
-
-#include "test.h"
-#include "config.h"
-
-#define CONF_FILE "/etc/deviced/auto-test.conf"
-#define DEF_PROFILE "mobile"
-
-static char section[256] = {'\0',};
-static GHashTable *config_hash = NULL;
-
-static int load_config(struct parse_result *result, void *user_data)
-{
- int value = 0;
-
- if (!MATCH(result->section, section))
- return 0;
-
- _D("%s,%s,%s", result->section, result->name, result->value);
-
- value = atoi(result->value);
- if ((value == 1) && !g_hash_table_contains(config_hash, result->name))
- g_hash_table_add(config_hash, g_strdup(result->name));
-
- return 0;
-}
-
-void test_config_load(const char *profile)
-{
- int len = 0;
- int ret = 0;
-
- if (NULL != profile) len = strlen(profile);
- if ((0 >= len) || (255 < len))
- strncpy(section, DEF_PROFILE, 255);
- else
- strncpy(section, profile, 255);
-
-
- if (NULL != config_hash)
- test_config_unload();
-
- config_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
- if (NULL == config_hash) {
- _E("Failed to create config hash table!");
- return ;
- }
-
- ret = config_parse(CONF_FILE, load_config, NULL);
-
- if (ret < 0) {
- _E("Failed to load %s, %d Use default value!", CONF_FILE, ret);
- test_config_unload();
- }
-}
-
-void test_config_unload()
-{
- if (NULL != config_hash) {
- g_hash_table_unref(config_hash);
- config_hash = NULL;
- }
-}
-
-bool test_config_is_supported(const char *module)
-{
- // if fail to load config file, all modules are supported as default.
- //if ((NULL == module) || (NULL == config_hash) || (0 == g_hash_table_size(config_hash)))
- if ((NULL == module) || (NULL == config_hash))
- return TRUE;
-
- return g_hash_table_contains(config_hash, module);
-}
+++ /dev/null
-/*
- * deviced
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * 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 __AUTOTEST_CONFIG_H__
-#define __AUTOTEST_CONFIG_H__
-
-#include <stdbool.h>
-
-void test_config_load(const char *profile);
-void test_config_unload();
-bool test_config_is_supported(const char *module);
-
-
-#endif /* __AUTOTEST_CONFIG_H__ */
.init = display_init,
.exit = display_exit,
.unit = display_unit,
+ .required_feature = "tizen.org/feature/display,tizen.org/feature/display.state",
};
TEST_OPS_REGISTER(&display_test_ops)
.init = ir_init,
.exit = ir_exit,
.unit = ir_unit,
+ .required_feature = "tizen.org/feature/consumer_ir",
};
TEST_OPS_REGISTER(&ir_test_ops)
.init = led_init,
.exit = led_exit,
.unit = led_unit,
+ .required_feature = "tizen.org/feature/led",
};
TEST_OPS_REGISTER(&led_test_ops)
*/
#include "test.h"
-#include "config.h"
static void test_main(int argc, char **argv)
{
_E("there is no test ops : %s", argv[2]);
return;
}
- ops->unit(argc, argv);
+
+ if (feature_supported(ops->required_feature))
+ ops->unit(argc, argv);
}
-void show_usage()
+void show_usage(void)
{
printf("Usage: deviced-auto-test [PROFILE] [MODULE] [UNIT-METHOD] [OPTS]\n\n");
printf("Mandatory arguments\n");
return 0;
}
- test_config_load(argv[1]);
- config_test();
-
if (argc >= 3)
unit_test(argc, argv);
else
test_main(argc, argv);
- test_config_unload();
-
return 0;
}
* limitations under the License.
*/
+#include <system_info.h>
+#include <string.h>
+
#include "test.h"
-#include "config.h"
static GList *dd_head;
+int feature_supported(const char *feature)
+{
+ char *token;
+ char *saveptr;
+ int retval;
+ bool supported;
+ char f[128] = {0, };
+ int ret = 1;
+
+ if (!feature)
+ return 1;
+
+ snprintf(f, sizeof(f) - 1, "%s", feature);
+
+ token = strtok_r(f, ",", &saveptr);
+ while (token) {
+ retval = system_info_get_platform_bool(token, &supported);
+ if (retval != 0 || supported == 0) {
+ _D("Feature %s not supported", token);
+ ret = 0;
+ break;
+ }
+
+ token = strtok_r(NULL, ",", &saveptr);
+ }
+
+ return ret;
+}
+
+
void add_test(const struct test_ops *d)
{
if (d->priority == TEST_PRIORITY_HIGH)
return NULL;
}
-void config_test()
-{
- GList *elem, *next;
- const struct test_ops *d;
-
- SYS_G_LIST_FOREACH_SAFE(dd_head, elem, next, d) {
- if (!test_config_is_supported(d->name))
- SYS_G_LIST_REMOVE(dd_head, d);
- }
-}
-
void test_init(void *data)
{
GList *elem;
_D("test module count(%d)", SYS_G_LIST_LENGTH(dd_head));
SYS_G_LIST_FOREACH(dd_head, elem, d) {
+ if (!feature_supported(d->required_feature))
+ continue;
+
_D("[%s] initialize", d->name);
if (d->init)
d->init(data);
const struct test_ops *d;
SYS_G_LIST_FOREACH(dd_head, elem, d) {
+ if (!feature_supported(d->required_feature))
+ continue;
+
_D("[%s] deinitialize", d->name);
if (d->exit)
d->exit(data);
struct test_ops {
enum test_priority priority;
char *name;
+ const char *required_feature;
void (*init) (void *data);
void (*exit) (void *data);
int (*start) (void);
void add_test(const struct test_ops *c);
void remove_test(const struct test_ops *c);
const struct test_ops *find_test(const char *name);
-void config_test();
void _R(const char *format, ...);
void __cb(GVariant *result, void *data, GError *err);
bool capi_result(const char *method, int val);
bool capi_reboot_result(const char *method, int val);
+int feature_supported(const char *feature);
#endif
.init = touchscreen_init,
.exit = touchscreen_exit,
.unit = touchscreen_unit,
+ .required_feature = "tizen.org/feature/display",
};
TEST_OPS_REGISTER(&touchscreen_test_ops)