summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/ConnectTest.java3
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/DlogTest.java62
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/ForwardTest.java125
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/GetStateTest.java2
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/PullPushTest.java167
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/RootTest.java37
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/ShellTest.java39
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/StartKillTest.java2
8 files changed, 377 insertions, 60 deletions
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/ConnectTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/ConnectTest.java
index b89964c5a..070dc1e91 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/ConnectTest.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/ConnectTest.java
@@ -68,7 +68,8 @@ public class ConnectTest {
public void test_connect() throws Exception {
class ConnectResult {
- @Pattern( pattern = LOOPBACK_IP + ":{0}\t{1}", index = 0 ) public String[] tcpPortNums;
+ @Pattern( pattern = LOOPBACK_IP + ":{0}\t{1}", index = 0 )
+ public String[] tcpPortNums;
}
try {
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/DlogTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/DlogTest.java
new file mode 100644
index 000000000..c1e24b0db
--- /dev/null
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/DlogTest.java
@@ -0,0 +1,62 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Shingil Kang <shingil.kang@samsung.com>
+ * Yoonki Park <yoonki.park@samsung.com>
+ *
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.sdb;
+
+import static org.junit.Assert.assertNotNull;
+import static org.tizen.common.Shell.run;
+import static org.tizen.common.sdb.SdbTestUtil.SDB_PATH;
+
+import org.junit.Test;
+import org.tizen.common.Pattern;
+
+public class DlogTest
+{
+ /**
+ * Test {sdb dlog}
+ *
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * sdb dlog
+ * expected result
+ * {Log level}/{Module}({PID}): {Source}: {log contents}
+ */
+ @Test
+ public void test_dlog() throws Exception {
+
+ class DlogResult {
+ @Pattern(pattern = "{0}/{1}({2})", index = 1)
+ public String module;
+ }
+
+ String[] serialNos = SdbTestUtil.getSerialNumber();
+ String serialNo = serialNos[0];
+
+ DlogResult result = run(String.format("%s -s %s dlog", SDB_PATH, serialNo)).expect(new DlogResult(), 500);
+
+ assertNotNull("debug output of dlog is null", result.module);
+ }
+}
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/ForwardTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/ForwardTest.java
new file mode 100644
index 000000000..eb446d95a
--- /dev/null
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/ForwardTest.java
@@ -0,0 +1,125 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Shingil Kang <shingil.kang@samsung.com>
+ * Yoonki Park <yoonki.park@samsung.com>
+ *
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.sdb;
+
+import static org.junit.Assert.assertTrue;
+import static org.tizen.common.sdb.SdbTestUtil.SDB_PATH;
+import static org.tizen.common.Shell.runAndWait;
+
+import java.text.MessageFormat;
+
+import org.junit.Test;
+
+public class ForwardTest
+{
+ public static final int DEFAULT_FORWARD_LIST_LINE_LENGTH = 2;
+ /**
+ * Test {sdb forward}
+ *
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * sdb forward tcp:{port} tcp:{port}
+ * expected result
+ * emulator-{port} tcp:{port} tcp:{port}
+ */
+ @Test
+ public void test_forward() throws Exception {
+ final String forward_port = "tcp:1111";
+
+ // add forward port
+ String[] serialNos = SdbTestUtil.getSerialNumber();
+ String serialNo = serialNos[0];
+ runAndWait(String.format("%s -s %s forward %s %s", SDB_PATH, serialNo, forward_port, forward_port));
+ String[] forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s forward --list", SDB_PATH), true);
+ assertTrue("cannot add forward port", forward_port_list.length > DEFAULT_FORWARD_LIST_LINE_LENGTH);
+ assertTrue(MessageFormat.format("forward port %s", forward_port_list[2]), forward_port_list[2].contains(forward_port));
+
+ // remove forward port
+ runAndWait(String.format("%s -s %s forward --remove %s", SDB_PATH, serialNo, forward_port));
+ }
+
+ /**
+ * Test {sdb forward --remove}
+ *
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * sdb forward --remove tcp:{port}
+ * expected result
+ * List of port fowarding
+ * SERIAL LOCAL REMOTE
+ */
+ @Test
+ public void test_forward_remove() throws Exception {
+ final String forward_port = "tcp:22222";
+
+ // add forward port
+ String[] serialNos = SdbTestUtil.getSerialNumber();
+ String serialNo = serialNos[0];
+ runAndWait(String.format("%s -s %s forward %s %s", SDB_PATH, serialNo, forward_port, forward_port));
+ String[] forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s forward --list", SDB_PATH), true);
+ assertTrue("cannot add forward port", forward_port_list.length > DEFAULT_FORWARD_LIST_LINE_LENGTH);
+ assertTrue(MessageFormat.format("forward port %s", forward_port_list[2]), forward_port_list[2].contains(forward_port));
+
+ // remove forward port
+ runAndWait(String.format("%s -s %s forward --remove %s", SDB_PATH, serialNo, forward_port));
+ String[] removed_forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s forward --list", SDB_PATH), true);
+ assertTrue("cannot remove forward port", removed_forward_port_list.length == DEFAULT_FORWARD_LIST_LINE_LENGTH);
+ }
+
+ /**
+ * Test {sdb forward --remove-all}
+ *
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * sdb forward remove-all
+ * expected result
+ * List of port fowarding
+ * SERIAL LOCAL REMOTE
+ */
+
+ @Test
+ public void test_forward_remove_all() throws Exception {
+ final String[] forward_ports = {"tcp:10001", "tcp:10002", "tcp:10003"};
+
+ // add many forward ports
+ String[] serialNos = SdbTestUtil.getSerialNumber();
+ String serialNo = serialNos[0];
+ for (int i = 0; i < forward_ports.length ; i++){
+ runAndWait(String.format("%s -s %s forward %s %s", SDB_PATH, serialNo, forward_ports[i], forward_ports[i]));
+ }
+
+ String[] forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s forward --list", SDB_PATH), true);
+ assertTrue("cannot add forward port", forward_port_list.length == forward_ports.length + DEFAULT_FORWARD_LIST_LINE_LENGTH);
+
+ // remove all forward ports
+ runAndWait(String.format("%s -s %s forward --remove-all", SDB_PATH, serialNo));
+ String[] removed_forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s forward --list", SDB_PATH), true);
+ assertTrue("cannot remove all forward ports", removed_forward_port_list.length == DEFAULT_FORWARD_LIST_LINE_LENGTH);
+ }
+} \ No newline at end of file
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/GetStateTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/GetStateTest.java
index 0f0ab78ee..bef732dc4 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/GetStateTest.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/GetStateTest.java
@@ -28,6 +28,7 @@ package org.tizen.common.sdb;
import static org.junit.Assert.*;
import static org.tizen.common.sdb.SdbTestUtil.SDB_PATH;
+import static org.tizen.common.Shell.runAndWait;
import java.text.MessageFormat;
@@ -55,6 +56,7 @@ public class GetStateTest {
String[] serialNos = SdbTestUtil.getSerialNumber();
String serialNo = serialNos[0];
+
String[] states = SdbTestUtil.runAndGetWholeString(String.format("%s -s %s get-state", SDB_PATH, serialNo), true);
assertTrue("cannot parse result of get-state", states.length > 0);
assertTrue(MessageFormat.format("unexpected state {0}", states[0]),
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/PullPushTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/PullPushTest.java
index 1fd1da3c8..3332b08a2 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/PullPushTest.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/PullPushTest.java
@@ -4,9 +4,9 @@
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Ho Namkoong <ho.namkoong@samsung.com>
+ * Ho Namkoong <ho.namkoong@samsung.com>
* BonYong Lee <bonyong.lee@samsung.com>
- *
+ *
* 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
@@ -41,20 +41,20 @@ import org.tizen.common.util.FileUtilTest;
/**
* <p>
* PullPushTest
- *
+ *
* Test case for sdb pull, push
*
* </p>
- *
+ *
* @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
*/
public class PullPushTest {
/**
* Test {sdb push, sdb pull (file)}
- *
+ *
* @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
- *
+ *
* command
* 1. create random text file 'push_file'
* 2. sdb shell rm -rf /tmp/push_file
@@ -65,12 +65,12 @@ public class PullPushTest {
*/
@Test
public void test_pushPullFile() throws Exception {
-
+
final String pushFileName = "push_file";
final String pullFileName = "pull_file";
final String tmpDir = "/tmp";
final String targetDst = tmpDir + "/" + pushFileName;
-
+
try {
pushPullAndCheck(pushFileName, targetDst, pullFileName, true);
}
@@ -85,12 +85,48 @@ public class PullPushTest {
}
}
}
-
+
+ /**
+ * Test {sdb -sudo push, sdb pull (file)}
+ *
+ * @author Shingil kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * 1. create random text file 'push_file'
+ * 2. sdb -sudo shell rm -rf /bin/push_file
+ * 3. sdb -sudo push push_file /bin/push_file
+ * 4. sdb -sudo pull /bin/push_file pull_file
+ * expected result
+ * contents of push_file and pull_file are same
+ */
+ @Test
+ public void test_sudo_pushPullFile() throws Exception {
+
+ final String pushFileName = "push_file";
+ final String pullFileName = "pull_file";
+ final String binDir = "/bin";
+ final String targetDst = binDir + "/" + pushFileName;
+
+ try {
+ pushPullAndCheck(pushFileName, targetDst, pullFileName, true, true);
+ }
+ finally {
+ File pushFile = new File(pushFileName);
+ if(pushFile.exists()) {
+ FileUtil.recursiveDelete(pushFile);
+ }
+ File pullFile = new File(pullFileName);
+ if(pullFile.exists()) {
+ FileUtil.recursiveDelete(pullFile);
+ }
+ }
+ }
+
/**
* Test {sdb push, sdb pull (directory)}
- *
+ *
* @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
- *
+ *
* command
* 1. create random directory 'push_dir'
* 2. sdb shell rm -rf /tmp/push_dir
@@ -101,7 +137,7 @@ public class PullPushTest {
*/
@Test
public void test_pushPullDir() throws Exception {
-
+
final String pushDirName = "push_dir";
final String pullDirName = "pull_dir";
final String tmpDir = "/tmp";
@@ -120,21 +156,65 @@ public class PullPushTest {
}
}
}
-
+
+ /**
+ * Test {sdb -sudo push, sdb pull (directory)}
+ *
+ * @author shingil kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * 1. create random directory 'push_dir'
+ * 2. sdb -sudo shell rm -rf /tmp/push_dir
+ * 3. sdb -sudo push push_dir /tmp/push_dir
+ * 4. sdb -sudo pull /tmp/push_dir pull_dir
+ * expected result
+ * contents of push_dir and pull_dir are same
+ */
+ @Test
+ public void test_sudo_pushPullDir() throws Exception {
+
+ final String pushDirName = "push_dir";
+ final String pullDirName = "pull_dir";
+ final String binDir = "/bin";
+ final String targetDst = binDir + "/" + pushDirName;
+ try {
+ pushPullAndCheck(pushDirName, targetDst, pullDirName, false, true);
+ }
+ finally {
+ File pushDir = new File(pushDirName);
+ if(pushDir.exists()) {
+ FileUtil.recursiveDelete(pushDir);
+ }
+ File pullDir = new File(pullDirName);
+ if(pullDir.exists()) {
+ FileUtil.recursiveDelete(pullDir);
+ }
+ }
+ }
+
private void pushPullAndCheck(String pushSrc, String pushDst, String pullDst, boolean file) throws Exception {
-
+ pushPullAndCheck(pushSrc,pushDst,pullDst,file, false);
+ }
+
+ private void pushPullAndCheck(String pushSrc, String pushDst, String pullDst, boolean file, boolean isRoot) throws Exception {
+ String sudo;
+ if(isRoot)
+ sudo = "-sudo";
+ else
+ sudo = "";
+
String[] results = null;
-
+
File pushFile = new File(pushSrc);
if(pushFile.exists()) {
FileUtil.recursiveDelete(pushFile);
}
-
+
File pullFile = new File(pullDst);
if(pullFile.exists()) {
FileUtil.recursiveDelete(pullFile);
}
-
+
String fileContent = "";
if(file) {
fileContent = generateRandomString(400, FILE_CONTENT_CHAR_LIST);
@@ -143,48 +223,48 @@ public class PullPushTest {
else {
generateRandomDir(pushFile, 5, 5, 3);
}
-
+
assertTrue(MessageFormat.format("fail to create file {0}", pushFile.getAbsolutePath()), pushFile.exists());
String serialNumber = getSerialNumber()[0];
- runAndWait( SDB_PATH + String.format(" -s %s shell rm -rf %s", serialNumber, pushDst));
- assertTrue(MessageFormat.format("rm fail to remove {0}", pushDst),
- checkTargetFileExist(pushDst, serialNumber, file, false));
- results = runAndGetWholeString( SDB_PATH + String.format(" -s %s push %s %s", serialNumber, pushFile.getAbsolutePath(), pushDst), false);
+ runAndWait( SDB_PATH + String.format(" %s -s %s shell rm -rf %s", sudo, serialNumber, pushDst));
+ assertTrue(MessageFormat.format("rm fail to remove {0}", pushDst),
+ checkTargetFileExist(pushDst, serialNumber, file, false, isRoot));
+ results = runAndGetWholeString( SDB_PATH + String.format(" %s -s %s push %s %s", sudo, serialNumber, pushFile.getAbsolutePath(), pushDst), false);
if(results != null) {
for(String result: results) {
- assertFalse(SDB_PATH + String.format(" -s %s push %s %s", serialNumber, pushFile.getAbsolutePath(), pushDst)
+ assertFalse(SDB_PATH + String.format(" %s -s %s push %s %s", sudo, serialNumber, pushFile.getAbsolutePath(), pushDst)
+ "makes error message: " + result, result.contains("error"));
}
}
-
- assertTrue(MessageFormat.format("{0} does not exist in target {1}", pushDst, serialNumber),
- checkTargetFileExist(pushDst, serialNumber, file, true));
- results = runAndGetWholeString( SDB_PATH + String.format(" -s %s pull %s %s", serialNumber, pushDst, pullFile.getAbsolutePath()), false);
-
+
+ assertTrue(MessageFormat.format("{0} does not exist in target {1}", pushDst, serialNumber),
+ checkTargetFileExist(pushDst, serialNumber, file, true, isRoot));
+ results = runAndGetWholeString( SDB_PATH + String.format(" %s -s %s pull %s %s", sudo, serialNumber, pushDst, pullFile.getAbsolutePath()), false);
+
if(results != null) {
for(String result: results) {
- assertFalse( SDB_PATH + String.format(" -s %s pull %s %s", serialNumber, pushDst, pullFile.getAbsolutePath())
+ assertFalse( SDB_PATH + String.format(" %s -s %s pull %s %s", sudo, serialNumber, pushDst, pullFile.getAbsolutePath())
+ "makes error message: " + result, result.contains("error"));
}
}
-
+
assertTrue(MessageFormat.format("{0} does not exist in host", pullFile.getAbsolutePath()), pullFile.exists());
-
+
if( file ) {
String result = FileUtil.readTextFile(pullFile, null);
- assertEquals(MessageFormat.format("pushed file {0} and pull file {1} are not same", pushFile.getAbsolutePath(), pullFile.getAbsolutePath()),
+ assertEquals(MessageFormat.format("pushed file {0} and pull file {1} are not same", pushFile.getAbsolutePath(), pullFile.getAbsolutePath()),
result, fileContent);
}
else {
List<File> notPushPullList = FileUtilTest.compareFiles(pushFile.getAbsolutePath(), pullFile.getAbsolutePath());
- assertTrue(String.format("Following files are not pushed or pulled\n%s",
+ assertTrue(String.format("Following files are not pushed or pulled\n%s",
listFiles(notPushPullList)), notPushPullList.size() == 0);
List<File> morePushPullList = FileUtilTest.compareFiles(pullFile.getAbsolutePath(), pushFile.getAbsolutePath());
- assertTrue(String.format("Following files are pushed or pulled but not in source\n%s", listFiles(morePushPullList)),
+ assertTrue(String.format("Following files are pushed or pulled but not in source\n%s", listFiles(morePushPullList)),
FileUtilTest.compareFiles(pullFile.getAbsolutePath(), pushFile.getAbsolutePath()).size() == 0);
}
}
-
+
private String listFiles(List<File> fileList) {
StringBuffer buffer = new StringBuffer();
for(File file: fileList) {
@@ -192,15 +272,26 @@ public class PullPushTest {
}
return buffer.toString();
}
-
+
private boolean checkTargetFileExist(String fileName, String serial, boolean file, boolean exist) throws Exception {
+ return checkTargetFileExist(fileName,serial, file, exist, false);
+ }
+
+ private boolean checkTargetFileExist(String fileName, String serial, boolean file, boolean exist, boolean isRoot) throws Exception {
+
+ String sudo;
+ if(isRoot)
+ sudo = "-sudo";
+ else
+ sudo = "";
+
String[] results = null;
for( int i =0; i < MAX_TRIAL; i++) {
if(file) {
- results = runAndGetWholeString(SDB_PATH + String.format(" -s %s shell ls %s", serial, fileName), true);
+ results = runAndGetWholeString(SDB_PATH + String.format(" %s -s %s shell ls %s", sudo, serial, fileName), true);
}
else {
- results = runAndGetWholeString(SDB_PATH + String.format(" -s %s shell ls -d %s", serial, fileName), true);
+ results = runAndGetWholeString(SDB_PATH + String.format(" %s -s %s shell ls -d %s", sudo, serial, fileName), true);
}
for(String result: results) {
if(exist) {
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/RootTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/RootTest.java
index 340246154..0ada401df 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/RootTest.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/RootTest.java
@@ -4,9 +4,9 @@
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
- * Ho Namkoong <ho.namkoong@samsung.com>
+ * Ho Namkoong <ho.namkoong@samsung.com>
* BonYong Lee <bonyong.lee@samsung.com>
- *
+ *
* 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
@@ -40,11 +40,11 @@ import org.tizen.common.Token;
/**
* <p>
* RootTest
- *
+ *
* Test case for sdb root on and sdb root off
*
* </p>
- *
+ *
* @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
*/
public class RootTest {
@@ -53,38 +53,38 @@ public class RootTest {
@Token(from = "Switched to", to = "account mode")
public String result;
}
-
+
/**
* Test {sdb root on}
- *
- * @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
+ *
+ * @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
*/
@Test
public void test_root_on() throws Exception {
-
+
String[] serials = getSerialNumber();
runAndWait(MessageFormat.format("{0} -s {1} {2}", SDB_PATH, serials[0], "root off"));
RootResult result = run(MessageFormat.format("{0} -s {1} {2}", SDB_PATH, serials[0], "root on"))
.expect(new RootResult());
-
+
assertNotNull("output of root on is null", result);
assertEquals("'root'", result.result);
runShellAndExpect(serials[0], "#");
}
-
+
/**
* Test {sdb root off}
- *
- * @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
+ *
+ * @author Ho Namkoong{@literal <ho.namkoong@samsung.com>} (S-Core)
*/
@Test
public void test_root_off() throws Exception {
-
+
String[] serials = getSerialNumber();
runAndWait(MessageFormat.format("{0} -s {1} {2}", SDB_PATH, serials[0], "root on"));
RootResult result = run(MessageFormat.format("{0} -s {1} {2}", SDB_PATH, serials[0], "root off")).
expect(new RootResult());
-
+
assertNotNull("output of root off is null", result);
assertEquals("'developer'", result.result);
runShellAndExpect(serials[0], "$");
@@ -92,15 +92,16 @@ public class RootTest {
private static void runShellAndExpect(String serial, String expect) throws Exception {
class RootShellResult {
- @Pattern(pattern = "sh-4.1{0}exit", index = 0)
+ @Pattern(pattern = "sh-{0}exit", index = 0)
public String token;
}
-
+
IShell shell = run(String.format("%s -s %s %s", SDB_PATH, serial, "shell"));
shell.write("exit", 1000);
RootShellResult result = shell.expect(new RootShellResult());
-
+
assertNotNull("output of shell is null", result.token);
- assertEquals(expect, result.token);
+ assertTrue("output of shell is not the expected value", result.token.contains(expect));
+
}
}
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/ShellTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/ShellTest.java
index ec3d2529b..1b077bf57 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/ShellTest.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/ShellTest.java
@@ -59,7 +59,7 @@ public class ShellTest {
boolean success = false;
for(String result: results) {
- if(result.contains("sh-4.1")) {
+ if(result.contains("sh-")) {
success = true;
break;
}
@@ -67,5 +67,40 @@ public class ShellTest {
assertTrue("fail to launch shell", success);
}
-
+
+ /**
+ * Test {sdb -sudo shell}
+ *
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * sdb -sudo shell whoami
+ * expected result
+ * root
+ */
+ @Test
+ public void test_sudo_shell_whoami() throws Exception {
+ String[] serialNos = SdbTestUtil.getSerialNumber();
+ String serialNo = serialNos[0];
+ String[] forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s -s %s -sudo shell whoami", SDB_PATH, serialNo), true);
+ assertEquals("cannot run shell with sudo privilege", "root" ,forward_port_list[0]);
+ }
+
+ /**
+ * Test {sdb -sudo shell}
+ *
+ * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
+ *
+ * command
+ * sdb shell whoami
+ * expected result
+ * developer
+ */
+ @Test
+ public void test_shell_whoami() throws Exception {
+ String[] serialNos = SdbTestUtil.getSerialNumber();
+ String serialNo = serialNos[0];
+ String[] forward_port_list = SdbTestUtil.runAndGetWholeString(String.format("%s -s %s shell whoami", SDB_PATH, serialNo), true);
+ assertEquals("cannot run shell with developer privilege", "developer" ,forward_port_list[0]);
+ }
}
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/StartKillTest.java b/org.tizen.common/test/src/org/tizen/common/sdb/StartKillTest.java
index b57d80821..773b1b985 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/StartKillTest.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/StartKillTest.java
@@ -72,7 +72,7 @@ public class StartKillTest {
boolean success = false;
for(String result: results) {
- if(result.contains("daemon not running")) {
+ if(result.contains("not running")) {
success = true;
break;
}