add chrome-renderer execute app 71/206071/1
authorwansuyoo <wansu.yoo@samsung.com>
Tue, 14 May 2019 05:19:23 +0000 (14:19 +0900)
committerwansuyoo <wansu.yoo@samsung.com>
Tue, 14 May 2019 05:24:28 +0000 (14:24 +0900)
re-define role of configuration member
- AppName: Unique name of app to distinguish
- ExecBinary: Execute full command with parameters

Change-Id: I70b71158c277d5ec5535ec8eece10ac2128d5a87
Signed-off-by: wansuyoo <wansu.yoo@samsung.com>
36 files changed:
.gitignore
Makefile
packaging/edge-orchestration.spec
src/CMain/inc/linux_aarch64/orchestration.h
src/CMain/inc/linux_arm/orchestration.h
src/CMain/inc/linux_x86-64/orchestration.h
src/CMain/inc/linux_x86/orchestration.h
src/CMain/lib/linux_aarch64/liborchestration.a
src/CMain/lib/linux_arm/liborchestration.a
src/CMain/lib/linux_x86-64/liborchestration.a
src/CMain/lib/linux_x86/liborchestration.a
src/interface/output/inc/linux_aarch64/liborchestration-0.0.1-20190514.1301.h [moved from src/interface/output/inc/linux_x86-64/liborchestration-0.0.1-20190429.1706.h with 100% similarity]
src/interface/output/inc/linux_arm/liborchestration-0.0.1-20190514.1301.h [moved from src/interface/output/inc/linux_x86/liborchestration-0.0.1-20190429.1714.h with 100% similarity]
src/interface/output/inc/linux_x86-64/liborchestration-0.0.1-20190514.1259.h [moved from src/interface/output/inc/linux_aarch64/liborchestration-0.0.1-20190429.1714.h with 100% similarity]
src/interface/output/inc/linux_x86/liborchestration-0.0.1-20190514.1301.h [moved from src/interface/output/inc/linux_arm/liborchestration-0.0.1-20190429.1714.h with 100% similarity]
src/interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190514.1301.a [moved from src/interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190429.1714.a with 79% similarity]
src/interface/output/lib/linux_arm/liborchestration-0.0.1-20190514.1301.a [moved from src/interface/output/lib/linux_arm/liborchestration-0.0.1-20190429.1714.a with 78% similarity]
src/interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190514.1259.a [moved from src/interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190429.1706.a with 79% similarity]
src/interface/output/lib/linux_x86/liborchestration-0.0.1-20190514.1301.a [moved from src/interface/output/lib/linux_x86/liborchestration-0.0.1-20190429.1714.a with 78% similarity]
src/libedge-orchestration/Makefile
src/libedge-orchestration/sample/main.c
src/libedge-orchestration/sample/main_chrome.c [new file with mode: 0755]
src/restapi/httpclient/internal_test.go
src/restapi/v1/restapi.go
src/restapi/v1/restapi_test.go
src/scoringmgr/mock/myscoring/libmyscoring.so.1.0.1
src/scoringmgr/mock/myscoring/myscoring.conf [changed mode: 0644->0755]
src/scoringmgr/mock/myscoring2/Makefile [new file with mode: 0755]
src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1 [deleted file]
src/scoringmgr/mock/myscoring2/libmyscoring2.so
src/scoringmgr/mock/myscoring2/libmyscoring2.so.1.0.1 [new file with mode: 0755]
src/scoringmgr/mock/myscoring2/myscoring.c [changed mode: 0644->0755]
src/scoringmgr/mock/myscoring2/myscoring2.conf [changed mode: 0644->0755]
src/servicemgr/service_execution.go
src/servicemgr/servicemgr.go
src/servicemgr/servicemgr_test.go

index 566d03c..bd916b6 100644 (file)
@@ -13,14 +13,19 @@ doc/generate-api/*
 # Sample binary
 src/libedge-orchestration/lib/*
 src/libedge-orchestration/sample/orchestration_sample
+src/libedge-orchestration/sample/orchestration_chrome_sample
 
 # Test binary, build with `go test -c`
 *.test
 
 # Output of c build 
 *.o
+src/CMain/unittest/out/*
 src/CMain/bin/*
 
+# Output of go build
+src/GoMain/bin/*
+
 # Output of the go coverage tool, specifically when used with LiteIDE
 *.out
 *.html
index be0b678..1dbaf32 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,12 @@ LIBSCORE_SAMPLE_VER          := 1.0.1
 LIBSCORE_SAMPLE_CONF   := myscoring.conf
 LIBSCORE_SAMPLE_DIR            := $(BASE_DIR)/src/scoringmgr/mock/myscoring
 
+LIBSCORE_SAMPLE_2                      := myscoring2
+LIBSCORE_SAMPLE_2_LIBRARY      := libmyscoring2.so
+LIBSCORE_SAMPLE_2_VER          := 1.0.1
+LIBSCORE_SAMPLE_2_CONF         := myscoring2.conf
+LIBSCORE_SAMPLE_2_DIR          := $(BASE_DIR)/src/scoringmgr/mock/myscoring2
+
 
 
 .DEFAULT_GOAL := help
@@ -113,6 +119,7 @@ build-dbus-client:
        ls -al $(LIBPKG_LIB_DIR)
        ls -al $(LIBPKG_INC_DIR)
        $(MAKE) -C $(LIBSCORE_SAMPLE_DIR)
+       $(MAKE) -C $(LIBSCORE_SAMPLE_2_DIR)
 
 ## install output files for packaing
 install:
@@ -125,6 +132,7 @@ install:
        install -d $(DESTDIR)/etc/dbus-1/system.d
        install -m 755 $(CMAIN_BIN_DIR)/$(CMAIN_BIN_FILE) $(DESTDIR)/usr/bin/$(CMAIN_BIN_FILE)
        install -m 755 $(LIBPKG_SAMPLE_DIR)/orchestration_sample $(DESTDIR)/usr/bin/orchestration_sample
+       install -m 755 $(LIBPKG_SAMPLE_DIR)/orchestration_chrome_sample $(DESTDIR)/usr/bin/orchestration_chrome_sample
        install -m 644 $(BASE_DIR)/$(SERVICE_FILE) $(DESTDIR)/usr/lib/systemd/system/$(SERVICE_FILE)
        ln -s ../$(SERVICE_FILE) $(DESTDIR)/usr/lib/systemd/system/multi-user.target.wants/
 
@@ -137,9 +145,11 @@ install:
        install -m 644 $(LIBPKG_INC_DIR)/$(LIBPKG_HEADER_FILE) $(DESTDIR)/usr/include/$(PKG_NAME)
 
        install -d $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE)
+       install -d $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE_2)
        install -m 644 $(LIBSCORE_SAMPLE_DIR)/$(LIBSCORE_SAMPLE_CONF) $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE)/
-#      install -m 644 $(LIBSCORE_SAMPLE_DIR)/$(LIBSCORE_SAMPLE_LIBRARY) $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE)/
+       install -m 644 $(LIBSCORE_SAMPLE_2_DIR)/$(LIBSCORE_SAMPLE_2_CONF) $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE_2)/
        install -m 644 $(LIBSCORE_SAMPLE_DIR)/$(LIBSCORE_SAMPLE_LIBRARY).$(LIBSCORE_SAMPLE_VER) $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE)/
+       install -m 644 $(LIBSCORE_SAMPLE_2_DIR)/$(LIBSCORE_SAMPLE_2_LIBRARY).$(LIBSCORE_SAMPLE_2_VER) $(DESTDIR)/etc/$(PKG_NAME)/$(LIBSCORE_SAMPLE_2)/
 
 ## go test and coverage
 test:
index 87aaadf..e4e97e3 100755 (executable)
@@ -97,6 +97,7 @@ systemctl restart %{name}
 
 %post -n libedge-orchestration
 ln -sf %{_sysconfdir}/%{name}/myscoring/libmyscoring.so.1.0.1 %{_sysconfdir}/%{name}/myscoring/libmyscoring.so
+ln -sf %{_sysconfdir}/%{name}/myscoring2/libmyscoring2.so.1.0.1 %{_sysconfdir}/%{name}/myscoring2/libmyscoring2.so
 
 %files
 %manifest %{name}.manifest
@@ -114,7 +115,9 @@ ln -sf %{_sysconfdir}/%{name}/myscoring/libmyscoring.so.1.0.1 %{_sysconfdir}/%{n
 %attr(755,system_fw,system_fw)%{_libdir}/liborchestration-client.so
 # orchestration sample
 %attr(755,system_fw,system_fw)%{_bindir}/orchestration_sample
+%attr(755,system_fw,system_fw)%{_bindir}/orchestration_chrome_sample
 %attr(755,system_fw,system_fw)%{_sysconfdir}/%{name}/myscoring/*
+%attr(755,system_fw,system_fw)%{_sysconfdir}/%{name}/myscoring2/*
 
 %files -n libedge-orchestration-devel
 %manifest lib%{name}.manifest
index 2a3a420..9f9712e 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/inc/linux_aarch64/liborchestration-0.0.1-20190429.1714.h
\ No newline at end of file
+../../../interface/output/inc/linux_aarch64/liborchestration-0.0.1-20190514.1301.h
\ No newline at end of file
index ff7372d..e11f5dd 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/inc/linux_arm/liborchestration-0.0.1-20190429.1714.h
\ No newline at end of file
+../../../interface/output/inc/linux_arm/liborchestration-0.0.1-20190514.1301.h
\ No newline at end of file
index 817ad8a..4184922 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/inc/linux_x86-64/liborchestration-0.0.1-20190429.1706.h
\ No newline at end of file
+../../../interface/output/inc/linux_x86-64/liborchestration-0.0.1-20190514.1259.h
\ No newline at end of file
index 4c21ef6..f1c05a7 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/inc/linux_x86/liborchestration-0.0.1-20190429.1714.h
\ No newline at end of file
+../../../interface/output/inc/linux_x86/liborchestration-0.0.1-20190514.1301.h
\ No newline at end of file
index f6157f3..958c363 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190429.1714.a
\ No newline at end of file
+../../../interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190514.1301.a
\ No newline at end of file
index 11d2f3a..6fa4b6b 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/lib/linux_arm/liborchestration-0.0.1-20190429.1714.a
\ No newline at end of file
+../../../interface/output/lib/linux_arm/liborchestration-0.0.1-20190514.1301.a
\ No newline at end of file
index 1f80869..8a82af6 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190429.1706.a
\ No newline at end of file
+../../../interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190514.1259.a
\ No newline at end of file
index 91288dd..244edcf 120000 (symlink)
@@ -1 +1 @@
-../../../interface/output/lib/linux_x86/liborchestration-0.0.1-20190429.1714.a
\ No newline at end of file
+../../../interface/output/lib/linux_x86/liborchestration-0.0.1-20190514.1301.a
\ No newline at end of file
similarity index 79%
rename from src/interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190429.1714.a
rename to src/interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190514.1301.a
index a76d2c2..745e623 100644 (file)
Binary files a/src/interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190429.1714.a and b/src/interface/output/lib/linux_aarch64/liborchestration-0.0.1-20190514.1301.a differ
similarity index 78%
rename from src/interface/output/lib/linux_arm/liborchestration-0.0.1-20190429.1714.a
rename to src/interface/output/lib/linux_arm/liborchestration-0.0.1-20190514.1301.a
index d87cc64..c13c3d6 100644 (file)
Binary files a/src/interface/output/lib/linux_arm/liborchestration-0.0.1-20190429.1714.a and b/src/interface/output/lib/linux_arm/liborchestration-0.0.1-20190514.1301.a differ
similarity index 79%
rename from src/interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190429.1706.a
rename to src/interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190514.1259.a
index 88860d7..bcf4507 100644 (file)
Binary files a/src/interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190429.1706.a and b/src/interface/output/lib/linux_x86-64/liborchestration-0.0.1-20190514.1259.a differ
similarity index 78%
rename from src/interface/output/lib/linux_x86/liborchestration-0.0.1-20190429.1714.a
rename to src/interface/output/lib/linux_x86/liborchestration-0.0.1-20190514.1301.a
index ccfc482..3ad7d1e 100644 (file)
Binary files a/src/interface/output/lib/linux_x86/liborchestration-0.0.1-20190429.1714.a and b/src/interface/output/lib/linux_x86/liborchestration-0.0.1-20190514.1301.a differ
index b231f37..1c19e77 100755 (executable)
@@ -22,6 +22,7 @@ all: build build-sample
 
 build-sample: build
        $(CC) -Wall -fPIE -pie $(SAMPLE_DIR)/main.c -o $(SAMPLE_DIR)/orchestration_sample -I$(INC_DIR) -L$(LIB_DIR) -lorchestration-client `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0`
+       $(CC) -Wall -fPIE -pie $(SAMPLE_DIR)/main_chrome.c -o $(SAMPLE_DIR)/orchestration_chrome_sample -I$(INC_DIR) -L$(LIB_DIR) -lorchestration-client `pkg-config --libs --cflags gio-2.0 gio-unix-2.0 glib-2.0`
        -rm -f ./sample/*.o
 
 build:
index c9b9cf6..489bccf 100755 (executable)
@@ -25,7 +25,7 @@ void status_cb(orchestration_service_status_e staus, void* user_data)
 
 int main() {
     orchestration_service_info_s service_info;
-    service_info.exec_parameter = "-al";
-    orchestration_request_service("ls", service_info, status_cb, NULL);
+    service_info.exec_parameter = "ls -al";
+    orchestration_request_service("list_segments", service_info, status_cb, NULL);
     return 0;
 }
\ No newline at end of file
diff --git a/src/libedge-orchestration/sample/main_chrome.c b/src/libedge-orchestration/sample/main_chrome.c
new file mode 100755 (executable)
index 0000000..a43ce3c
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2019 Samsung Electronics 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 <orchestration_client.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+
+int get_ip_addr(char ipstr[40]) {
+    int fd;
+    struct ifreq ifr;
+
+    fd = socket(AF_INET, SOCK_DGRAM, 0);
+    ifr.ifr_addr.sa_family = AF_INET;
+
+    /* I want IP address attached to "wlan0" */
+    strncpy(ifr.ifr_name, "wlan0", IFNAMSIZ-1);
+    ioctl(fd, SIOCGIFADDR, &ifr);
+    close(fd);
+
+    strcpy(ipstr, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
+    return 0;
+}
+
+void status_cb(orchestration_service_status_e staus, void* user_data)
+{
+
+}
+
+int main() {
+    char command[256] = "/usr/share/chromium-efl/bin/efl_webprocess --type=renderer --enable-castanets=";
+    char ipstr[40] = {0, };
+    if (get_ip_addr(ipstr) != 0) {
+        printf("error from getting ip addr\n");
+        return 0;
+    }
+    orchestration_service_info_s service_info;
+    service_info.exec_parameter = strcat(command, ipstr);
+    printf("service_info.exec_parameter: %s\n", service_info.exec_parameter);
+    orchestration_request_service("org.tizen.chromium-efl", service_info, status_cb, NULL);
+    return 0;
+}
\ No newline at end of file
index 2feb0d4..1373943 100644 (file)
@@ -45,10 +45,12 @@ var (
 
        targetCustomURL        = fmt.Sprintf("127.0.0.1:%d", httpclient.ConstWellknownPort)
        targetRemoteDeviceAddr = "127.0.0.1"
-       notExistFileName       = "NotExistFile"
        keyFilePath            = "../../securemgr/test/key.txt"
 
        serviceName = "ls"
+
+       userArgs         = []string{"ls", "-ail"}
+       userArgsNotExist = []string{"NotExistFile"}
 )
 
 func init() {
@@ -77,6 +79,7 @@ func TestDoExecuteRemoteDevice(t *testing.T) {
 
        appInfo := make(map[string]interface{})
        appInfo["ServiceName"] = serviceName
+       appInfo["UserArgs"] = userArgs
        appInfo["NotificationTargetURL"] = targetRemoteDeviceAddr
 
        err := httpclient.DoExecuteRemoteDevice(appInfo, targetRemoteDeviceAddr)
@@ -92,7 +95,8 @@ func TestDoExecuteRemoteDeviceWithInvalidApp(t *testing.T) {
        setUp()
 
        appInfo := make(map[string]interface{})
-       appInfo["ServiceName"] = notExistFileName
+       appInfo["ServiceName"] = serviceName
+       appInfo["UserArgs"] = userArgsNotExist
        err := httpclient.DoExecuteRemoteDevice(appInfo, targetRemoteDeviceAddr)
 
        log.Println("[err]", err)
index 44ab922..bf09c42 100755 (executable)
@@ -195,7 +195,7 @@ func executeServiceHandler(w http.ResponseWriter, req *http.Request) (distServic
                return
        }
 
-       _, err = exec.LookPath(distService["ServiceName"].(string))
+       _, err = exec.LookPath((distService["UserArgs"].([]interface{}))[0].(string))
        if err != nil {
                err = errors.New("It is Invalid Service")
                return
index f28c4eb..2803bd0 100755 (executable)
@@ -49,15 +49,19 @@ const (
        // Scoring mgr URI
        ConstScoremgrScore = "/api/v1/scoringmgr/score"
 
-       ConstAppName         = "ls"
-       ConstNotExistAppName = "NotExistFile"
-       ConstTooLongAppName  = `00000000000000000000000000000000000000000000000000000000000000000000000000000000000
+       ConstAppName        = "ls"
+       ConstTooLongAppName = `00000000000000000000000000000000000000000000000000000000000000000000000000000000000
                                                        00000000000000000000000000000000000000000000000000000000000000000000000000000000000
                                                        00000000000000000000000000000000000000000000000000000000000000000000000000000000000
                                                        00000000000000000000000000000000000000000000000000000000000000000000000000000000000
                                                        00000000000000000000000000000000000000000000000000000000000000000000000000000000000`
 )
 
+var (
+       userArgs         = []string{"ls", "-ail"}
+       userArgsNotExist = []string{"invalidArgs"}
+)
+
 type Response struct {
        Content string
        Code    int
@@ -95,11 +99,11 @@ func TestAPIV1DiscoverymgrDevicesTXTPostWithInvalidAppName(t *testing.T) {
 }
 
 func TestAPIV1ServicemgrServicesPost(t *testing.T) {
-       executeService(t, ConstAppName, http.StatusOK)
+       executeService(t, ConstAppName, userArgs, http.StatusOK)
 }
 
 func TestAPIV1ServicemgrServicesPostWithNotExistExecutionFile(t *testing.T) {
-       executeService(t, ConstNotExistAppName, http.StatusBadRequest)
+       executeService(t, ConstAppName, userArgsNotExist, http.StatusBadRequest)
 }
 
 func TestAPIV1ScoringmgrScoreLibnameGet(t *testing.T) {
@@ -178,7 +182,7 @@ func testPost(t *testing.T, targetURI string, bodyContents []byte, statusCode in
        return
 }
 
-func executeService(t *testing.T, appName string, expectedStatus int) {
+func executeService(t *testing.T, appName string, userArgs []string, expectedStatus int) {
        t.Helper()
        targetURI := ConstServicemgrServices
 
@@ -187,8 +191,6 @@ func executeService(t *testing.T, appName string, expectedStatus int) {
        appInfo["ServiceID"] = 1
        appInfo["ServiceName"] = appName
        appInfo["NotificationTargetURL"] = "URL"
-
-       userArgs := []string{"-ail"}
        appInfo["UserArgs"] = userArgs
 
        bdbytes, err := json.Marshal(appInfo)
index 0a6f3bd..9b7ccbe 100755 (executable)
Binary files a/src/scoringmgr/mock/myscoring/libmyscoring.so.1.0.1 and b/src/scoringmgr/mock/myscoring/libmyscoring.so.1.0.1 differ
old mode 100644 (file)
new mode 100755 (executable)
index bd84c46..7994425
@@ -3,7 +3,7 @@
 ConfVersion=v0.0                                        ; Version of Configuration file
 
 [ServiceInfo]
-ServiceName=ls                              ; Name of distributed service
+ServiceName=list_segments                              ; Name of distributed service
 
 [ScoringMethod]
 LibFile=./libmyscoring.so                               ; Library file name
diff --git a/src/scoringmgr/mock/myscoring2/Makefile b/src/scoringmgr/mock/myscoring2/Makefile
new file mode 100755 (executable)
index 0000000..3360ae7
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# Makefile
+#
+
+# Target parameters
+LIBRARY_FILE   := libmyscoring2.so
+LIBRARY_VER            := 1.0.1
+SRC_FILES              := \
+                       myscoring.c
+CONF_FILE              := myscoring2.conf
+OBJ_FILES              := *.o
+
+# Build parameter
+
+all: clean build
+
+build:
+       $(CC) -fPIC -c $(SRC_FILES)
+       $(CC) -shared -o $(LIBRARY_FILE).$(LIBRARY_VER) $(OBJ_FILES) -lm
+       ln -sf $(LIBRARY_FILE).$(LIBRARY_VER) $(LIBRARY_FILE)
+       -rm -f $(OBJ_FILES)
+
+clean:
+       -rm -f $(OBJ_FILES)
+       -rm -f $(LIBRARY_FILE).$(LIBRARY_VER)
+       -rm -f $(LIBRARY_FILE)
+
+.PHONY: build clean
\ No newline at end of file
diff --git a/src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1 b/src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1
deleted file mode 100755 (executable)
index 582a2f0..0000000
Binary files a/src/scoringmgr/mock/myscoring2/libmyscoring.so.1.0.1 and /dev/null differ
index 50bdf3c..e20959d 120000 (symlink)
@@ -1 +1 @@
-libmyscoring.so.1.0.1
\ No newline at end of file
+libmyscoring2.so.1.0.1
\ No newline at end of file
diff --git a/src/scoringmgr/mock/myscoring2/libmyscoring2.so.1.0.1 b/src/scoringmgr/mock/myscoring2/libmyscoring2.so.1.0.1
new file mode 100755 (executable)
index 0000000..9b7ccbe
Binary files /dev/null and b/src/scoringmgr/mock/myscoring2/libmyscoring2.so.1.0.1 differ
old mode 100644 (file)
new mode 100755 (executable)
index 85ea3a9..0273fb9
@@ -1,6 +1,6 @@
 
 /*
-$ gcc -fPIC -c myscoring.c && gcc -shared -o -lm libmyscoring.so.1.0.1 myscoring.o -lm
+$ gcc -fPIC -c myscoring.c && gcc -shared -o libmyscoring.so.1.0.1 myscoring.o -lm
 $ ln -rs libmyscoring.so.1.0.1 libmyscoring.so
 */
 
@@ -84,3 +84,33 @@ double myscoring2(double (*getResource)(const char *))
 
   return score;
 }
+
+#define MY_SCORING_3_CNT 4
+double myscoring3(double (*getResource)(const char *))
+{
+
+  // printf("myscoring\n");
+
+  double score;
+  const char *resourceNames[MY_SCORING_3_CNT] = {"cpu/usage", "cpu/count", "memory/free", "memory/available"};
+  double W[MY_SCORING_3_CNT] = {1.48271, 4.125421, 5.3381723, 9.194717234};
+  double resourceValues[MY_SCORING_3_CNT];
+
+  // double someResource;
+  // someResource = getResource("some/usage");
+  // assert(isnan(someResource));
+
+  for (int i = 0; i < MY_SCORING_3_CNT; i++)
+  {
+    resourceValues[i] = getResource(resourceNames[i]);
+    // printf("resourceNames : %s %f\n", resourceNames[i], resourceValues[i]);
+  }
+
+  score = 0.0;
+  for (int i = 0; i < MY_SCORING_3_CNT; i++)
+  {
+    score += resourceValues[i] * W[i];
+  }
+
+  return score;
+}
old mode 100644 (file)
new mode 100755 (executable)
index abf934d..6ba9258
@@ -3,11 +3,11 @@
 ConfVersion=v0.0                                        ; Version of Configuration file
 
 [ServiceInfo]
-ServiceName=ll                              ; Name of distributed service
+ServiceName=org.tizen.chromium-efl                              ; Name of distributed service
 
 [ScoringMethod]
 LibFile=./libmyscoring.so                               ; Library file name
-FunctionName=myscoring2
+FunctionName=myscoring3
 
 [ResourceType]
 IntervalTimeMs=1000                                     ; Interval time of get resource
index 6c88452..df58266 100755 (executable)
@@ -18,6 +18,8 @@
 package servicemgr
 
 import (
+       "bufio"
+       "errors"
        "log"
        "os"
        "os/exec"
@@ -39,6 +41,7 @@ func (p Service) execute() (err error) {
 
        cmd, pid, err := p.setService()
        if err != nil {
+               log.Println(err)
                return
        }
        log.Println(logPrefix, "Just ran subprocess ", pid)
@@ -57,20 +60,50 @@ func (p Service) execute() (err error) {
 }
 
 func (p Service) setService() (cmd *exec.Cmd, pid int, err error) {
-       if len(p.paramStr) == 0 {
-               cmd = exec.Command(p.serviceName)
-       } else {
-               cmd = exec.Command(p.serviceName, p.paramStr...)
+       if len(p.paramStr) < 1 {
+               err = errors.New("error: empty parameter")
+               return
        }
+       cmd = exec.Command(p.paramStr[0], p.paramStr[1:]...)
+
+       // set "owner" account: need to execute user app
+       /*
+               execUser, _ := user.Lookup("owner")
+
+               uid, _ := strconv.Atoi(execUser.Uid)
+               gid, _ := strconv.Atoi(execUser.Gid)
+               groups, _ := execUser.GroupIds()
+
+               var gids = []uint32{}
+               for _, i := range groups {
+                       id, _ := strconv.Atoi(i)
+                       gids = append(gids, uint32(id))
+               }
+
+               log.Printf("uid(%d), gid(%d)", uid, gid)
+               log.Printf("groupIds: %v", gids)
 
-       cmd.Stdout = os.Stdout
+               cmd.SysProcAttr = &syscall.SysProcAttr{}
+               cmd.SysProcAttr.Credential = &syscall.Credential{
+                       Uid:    uint32(uid),
+                       Gid:    uint32(gid),
+                       Groups: gids,
+               }
+       */
 
+       stdout, _ := cmd.StdoutPipe()
        err = cmd.Start()
        if err != nil {
                log.Println(logPrefix, err.Error())
                return
        }
 
+       scanner := bufio.NewScanner(stdout)
+       for scanner.Scan() {
+               m := scanner.Text()
+               log.Println(m)
+       }
+
        pid = cmd.Process.Pid
 
        return
index 52c71f8..3e2358f 100755 (executable)
@@ -127,7 +127,7 @@ func checkError(err error) bool {
 
 func executeLocalEnv(appInfo map[string]interface{}) (err error) {
        //  check execution validation
-       _, err = exec.LookPath(appInfo[ConstKeyServiceName].(string))
+       _, err = exec.LookPath((appInfo[ConstKeyUserArgs].([]string))[0])
 
        if checkError(err) == false {
                go Run(appInfo)
index bd652ee..b70ba36 100755 (executable)
@@ -33,6 +33,12 @@ const (
 )
 
 var (
+       paramStr                = []string{"ls"}
+       paramStrWithArgs        = []string{"ls", "-ail"}
+       paramStrWithInvalidArgs = []string{"ls", "invalidArgs"}
+)
+
+var (
        targetLocalAddr, _ = common.GetOutboundIP()
        serviceID          uint64
        // notExistFileName       = "NotExistFile"
@@ -45,7 +51,7 @@ func init() {
 func TestExecuteApp(t *testing.T) {
        notiChan := make(chan string)
 
-       _, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, nil, notiChan)
+       _, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, paramStr, notiChan)
        checkError(t, err)
 
        time.Sleep(time.Millisecond * 10)
@@ -54,8 +60,7 @@ func TestExecuteApp(t *testing.T) {
 func TestExecuteAppWithArgs(t *testing.T) {
        notiChan := make(chan string)
 
-       args := []string{"-ail"}
-       _, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, args, notiChan)
+       _, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, paramStrWithArgs, notiChan)
        checkError(t, err)
 
        select {
@@ -72,8 +77,7 @@ func TestExecuteAppWithArgs(t *testing.T) {
 func TestExecuteAppWithInvalidArgs(t *testing.T) {
        notiChan := make(chan string)
 
-       args := []string{"invalidArgs"}
-       _, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, args, notiChan)
+       _, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, paramStrWithInvalidArgs, notiChan)
        checkError(t, err)
 
        select {
@@ -90,7 +94,7 @@ func TestExecuteAppWithInvalidArgs(t *testing.T) {
 func TestHandleNoti(t *testing.T) {
        notiChan := make(chan string, 1)
 
-       id, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, nil, notiChan)
+       id, err := servicemgr.ExecuteApp(targetLocalAddr, serviceName, paramStr, notiChan)
        checkError(t, err)
 
        statusNotificationRequest := make(map[string]interface{})