summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorho.namkoong <ho.namkoong@samsung.com>2013-09-17 17:43:11 +0900
committerho.namkoong <ho.namkoong@samsung.com>2013-09-17 17:43:11 +0900
commit25d27a8469f75d9061f214cf8801cd4ca96383c9 (patch)
treedbe9f10272f531a348e914ceb617a454e9f66ecd
parent494a0dbbcd8ef1648b7e8a71d4edccd6720b5a04 (diff)
downloadcommon-eplugin-25d27a8469f75d9061f214cf8801cd4ca96383c9.tar.gz
common-eplugin-25d27a8469f75d9061f214cf8801cd4ca96383c9.tar.bz2
common-eplugin-25d27a8469f75d9061f214cf8801cd4ca96383c9.zip
[Title] fix test case bug
[Type] [Module] [Priority] [CQ#] [Redmine#] 9903 [Problem] [Cause] [Solution] [TestCase] Change-Id: I41746c543ca28d680a1e4d4759b20d1421c343aa
-rw-r--r--org.tizen.common/test/src/org/tizen/common/Shell.java24
-rw-r--r--org.tizen.common/test/src/org/tizen/common/sdb/SdbTestUtil.java13
2 files changed, 32 insertions, 5 deletions
diff --git a/org.tizen.common/test/src/org/tizen/common/Shell.java b/org.tizen.common/test/src/org/tizen/common/Shell.java
index ee0a07e9f..886f15883 100644
--- a/org.tizen.common/test/src/org/tizen/common/Shell.java
+++ b/org.tizen.common/test/src/org/tizen/common/Shell.java
@@ -39,6 +39,7 @@ import java.text.MessageFormat;
import java.text.ParseException;
import org.tizen.sdblib.daemon.ServerState;
+import org.tizen.sdblib.util.Log;
import org.tizen.sdblib.util.StreamGobbler;
/**
@@ -121,6 +122,11 @@ implements IShell
final BufferedWriter out;
/**
+ * Checker for waitFor is done
+ */
+ boolean waitForFin;
+
+ /**
* Constructor with command and boot the input and error stream
*
* @param cmd command to execution
@@ -137,9 +143,23 @@ implements IShell
in = new StreamGobbler( process.getInputStream() );
error = new StreamGobbler( process.getErrorStream() );
out = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
+ waitForFin = false;
in.boot();
error.boot();
+
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ process.waitFor();
+ waitForFin = true;
+ } catch (InterruptedException e) {
+ Log.e("Exception occurred", e);
+ }
+ }
+ }).start();
}
/** (non-Javadoc)
@@ -190,12 +210,12 @@ implements IShell
throws Exception
{
// Check done
- while ( TIMEOUT > currentTimeMillis() - startTime && ( !in.isState( ServerState.Terminated ) ) )
+ while ( TIMEOUT > currentTimeMillis() - startTime && ( !in.isState( ServerState.Terminated ) ) && !waitForFin)
{
trySleep( 200 );
}
- if( !in.isState(ServerState.Terminated)) {
+ if( !in.isState(ServerState.Terminated) && !waitForFin) {
return instance;
}
diff --git a/org.tizen.common/test/src/org/tizen/common/sdb/SdbTestUtil.java b/org.tizen.common/test/src/org/tizen/common/sdb/SdbTestUtil.java
index 5350fe99d..b2fbe66a0 100644
--- a/org.tizen.common/test/src/org/tizen/common/sdb/SdbTestUtil.java
+++ b/org.tizen.common/test/src/org/tizen/common/sdb/SdbTestUtil.java
@@ -36,6 +36,7 @@ import org.tizen.common.IShell;
import org.tizen.common.Pattern;
import org.tizen.common.util.FileUtil;
import org.tizen.common.util.StringUtil;
+import org.tizen.sdblib.util.Log;
/**
* <p>
@@ -65,10 +66,12 @@ class SdbTestUtil {
}
}
+ static final String FILE_NAME_CHAR_WITHOUT_WHITE_SPACE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+
/**
* File name characters for generating random file name
*/
- static final String FILE_NAME_CHAR_LIST = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ";
+ static final String FILE_NAME_CHAR_LIST = FILE_NAME_CHAR_WITHOUT_WHITE_SPACE + " ";
/**
* File content characters for generating random file contents
@@ -156,7 +159,7 @@ class SdbTestUtil {
Random random = new Random();
final int fileLen = random.nextInt(maxLen) + 1;
- return generateRandomString(fileLen, FILE_NAME_CHAR_LIST);
+ return generateRandomString(fileLen - 1, FILE_NAME_CHAR_LIST) + generateRandomString(1, FILE_NAME_CHAR_WITHOUT_WHITE_SPACE);
}
/**
@@ -172,17 +175,20 @@ class SdbTestUtil {
dir.mkdir();
Random random = new Random();
- int randomFile = random.nextInt(maxFile);
+ //at least one file
+ int randomFile = random.nextInt(maxFile - 1) + 1;
for(int i =0; i< randomFile; i++) {
File childFile = new File(dir, generateRandomFileName());
while(childFile.exists()) {
childFile = new File(dir, generateRandomFileName());
}
+ Log.i("FILE CREATING", String.format("file %s is being created", childFile.getAbsolutePath()));
String content = generateRandomString(random.nextInt(50), FILE_CONTENT_CHAR_LIST);
FileUtil.createTextFile(childFile, content, null);
}
if(maxDepth < 1) {
+ //do not create more directory
return;
}
@@ -194,6 +200,7 @@ class SdbTestUtil {
childDir = new File(dir, generateRandomFileName());
}
+ Log.i("DIR CREATING", String.format("directory %s is being created", childDir.getAbsolutePath()));
generateRandomDir(childDir, maxDepth - 1, maxFile, maxDir);
}
}