diff options
author | Ivaylo Asenov <ivaylo.asenov@linaro.org> | 2016-09-09 12:17:57 +0300 |
---|---|---|
committer | Ivaylo Asenov <ivaylo.asenov@linaro.org> | 2016-09-09 12:18:11 +0300 |
commit | e604ea04f19ca2c5c02e5e639d3ed643bf80149f (patch) | |
tree | 1dca6d0244a8143b574e83d59deb3b8122ca0a65 | |
parent | dda723a9709d50f61837cb0023e5a3fbf5e045ec (diff) | |
download | benchmark-e604ea04f19ca2c5c02e5e639d3ed643bf80149f.tar.gz |
Add Bonnie++ as executable.
Add stream for reading standard error in results.
Add example *.sh script that use "adb setprop" to run chosen tests with benchmark application using adb shell.
Add option to run tests multiple times.
Some layout changes done.
Change-Id: I92cc42961386d5b4a21a7a44ea4336aceb82b559
Signed-off-by: Ivaylo Asenov <ivaylo.asenov@linaro.org>
21 files changed, 838 insertions, 213 deletions
diff --git a/BenchmarkFramework/Readme.txt b/BenchmarkFramework/Readme.txt index 241df5f..2b23534 100644 --- a/BenchmarkFramework/Readme.txt +++ b/BenchmarkFramework/Readme.txt @@ -27,15 +27,23 @@ This file includes a little info about "benchmarkframework" application. // Source code: http://www.iozone.org/ // Version: Iozone3_465 +- "Bonnie++" // This benchmark is integrated as executable file related to task: https://projects.linaro.org/browse/LMG-1420 + // Source code: "ssh://git@git.linaro.org/people/satish.patel/android-bonnie.git" + 3)Functionality: 3.1) Select one or more tests and run them by pressing [RUN TEST] button. After all selected tests are finished the results for them will be saved automaticaly. - 3.2) Pressing [RUN AUTO] button starts all 6 tests one by one in row. After all tests are finished the results for them will be saved automaticaly. + 3.2) Pressing [RUN AUTO] button starts all tests one by one in row. After all tests are finished the results for them will be saved automaticaly. 3.3) Pressing [i] button give some help about the usage. 3.4) [SAVE] button save result shown on UI (display) to text file (Not needed anymore and will be removed in future) + 3.5) Application "Settting" allow to select how many times tests will run (multiple times running) + +4)Shell script: There is shell script in "BenchmarkFramework/shellscript" which allows benchmark application to be run using adb shell properties. + If you use the script be sure that you have root access to device and "APP_PATH" parameter is set properly. + -4)Notes: The started test cannot be stopped for now (No "Cancel" button on ProgressDialog) so wait until test is finished. The most time consumer test is "Linaro-StringBench". +5)Notes: The started test cannot be stopped for now (No "Cancel" button on ProgressDialog) so wait until test is finished. The most time consumer test is "Linaro-StringBench". If there are some issues use logcat for more info. diff --git a/BenchmarkFramework/app/src/main/AndroidManifest.xml b/BenchmarkFramework/app/src/main/AndroidManifest.xml index 93c61e7..c871955 100644 --- a/BenchmarkFramework/app/src/main/AndroidManifest.xml +++ b/BenchmarkFramework/app/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ <application android:allowBackup="true" - android:icon="@mipmap/ic_launcher" + android:icon="@mipmap/benchmark" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" > diff --git a/BenchmarkFramework/app/src/main/assets/bonnie b/BenchmarkFramework/app/src/main/assets/bonnie Binary files differnew file mode 100644 index 0000000..c60b39c --- /dev/null +++ b/BenchmarkFramework/app/src/main/assets/bonnie diff --git a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/BaseBenchmark.java b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/BaseBenchmark.java index 3082dde..a826d2e 100644 --- a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/BaseBenchmark.java +++ b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/BaseBenchmark.java @@ -257,7 +257,7 @@ public class BaseBenchmark { String executableFilePath = MainActivity.EXECUTABLE_PATH; StringBuilder log = null; - File dir_local = new File(executableFilePath); + //File dir_local = new File(executableFilePath); String currentCommand = ""; String result = ""; @@ -298,24 +298,38 @@ public class BaseBenchmark { File execFile = new File(executableFilePath + "/" + executable_filename); execFile.setExecutable(true); - Process process = Runtime.getRuntime().exec(executableFilePath + "/" + executable_filename + " " + currentCommand, null, dir_local); + Process process = Runtime.getRuntime().exec(executableFilePath + "/" + executable_filename + " " + currentCommand, null, dir); Log.i(TAG, "process:" + process.toString()); Log.i(TAG, "Execute: "+ executable_filename + " " + currentCommand); - BufferedReader bufferedReader = new BufferedReader( + BufferedReader bufferedReader_stdOut = new BufferedReader( new InputStreamReader(process.getInputStream())); + BufferedReader bufferedReader_stdErr = new BufferedReader( + new InputStreamReader(process.getErrorStream())); + String separator = System.getProperty("line.separator"); log = new StringBuilder(); String line; - while ((line = bufferedReader.readLine()) != null) { + while ((line = bufferedReader_stdOut.readLine()) != null) { + line = line.replace("null", ""); + log.append(line); + log.append(separator); + log.append(separator); + Log.i(TAG, "*****************" + line); + } + + log.append("StdOut Errors:"); + while ((line = bufferedReader_stdErr.readLine()) != null) { line = line.replace("null", ""); log.append(line); log.append(separator); log.append(separator); Log.i(TAG, "*****************" + line); } + log.append(separator); + log.append(separator); result = result + log.toString(); process.destroy(); diff --git a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java index 45cab75..1f34c9b 100644 --- a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java +++ b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/MainActivity.java @@ -1,40 +1,58 @@ package org.linaro.iasenov.benchmarkframework; +import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.content.res.AssetManager; +import android.content.res.Configuration; import android.graphics.Color; import android.graphics.Typeface; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; +import android.os.Environment; import android.os.Handler; import android.os.Message; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.text.Editable; import android.text.Html; +import android.text.InputType; import android.text.method.ScrollingMovementMethod; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MenuInflater; import android.view.View; import android.view.Menu; import android.view.MenuItem; +import android.view.ViewGroup; import android.view.Window; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.EditText; import android.widget.ListView; +import android.widget.NumberPicker; import android.widget.Toast; import android.widget.TextView; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -45,7 +63,9 @@ import java.math.BigInteger; import java.nio.channels.FileChannel; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; +import java.util.Properties; public class MainActivity extends AppCompatActivity implements View.OnClickListener { @@ -57,6 +77,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe private Button mInfo; private ListView mListView; private TextView mDisplayDetails; + private TextView mToolbarRepeatIndicator; private String mSelectedTest = ""; private String mSelectedClassTest = ""; @@ -88,10 +109,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe public File autoTestFile; //file for auto saving tests results(when isAuto); - final String[] classNameTestItems = new String[7]; + final String[] classNameTestItems = new String[8]; public ArrayAdapter listAdapter; - + private String KEY_REPEAT_NUMBER = "repeat-number"; + public String mRepeatNumber=""; + public int endTestCounter; //********************************************************************************************** @Override @@ -103,23 +126,44 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe mActivity = this; + //Get device info + Log.i(TAG, getInfosAboutDevice(this)); + PACKAGE_NAME = getApplicationContext().getPackageName(); - mStartButton = (Button)findViewById(R.id.startButton); + mStartButton = (Button) findViewById(R.id.startButton); mStartButton.setOnClickListener(this); - mStartAutoButton = (Button)findViewById(R.id.startAutoButton); + + + //Load repeat number tests from preferences + //*************************************************** + SharedPreferences prefs = getPreferences(MODE_PRIVATE); + mRepeatNumber = prefs.getString(KEY_REPEAT_NUMBER,"1"); + + + // Find the toolbar view inside the activity layout + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + // Sets the Toolbar to act as the ActionBar for this Activity window. + // Make sure the toolbar exists in the activity and is not null + setSupportActionBar(toolbar); + + mToolbarRepeatIndicator = (TextView) findViewById(R.id.toolbar_repeat_indicator); + mToolbarRepeatIndicator.setText(" "+mRepeatNumber+" "); + + + mStartAutoButton = (Button) findViewById(R.id.startAutoButton); mStartAutoButton.setOnClickListener(this); - mSaveButton = (Button)findViewById(R.id.saveButton); + mSaveButton = (Button) findViewById(R.id.saveButton); mSaveButton.setOnClickListener(this); - mInfo = (Button)findViewById(R.id.infoButton); + mInfo = (Button) findViewById(R.id.infoButton); mInfo.setOnClickListener(this); mListView = (ListView) findViewById(R.id.tests_list_view); - mDisplayDetails = (TextView)findViewById(R.id.displayDetails); + mDisplayDetails = (TextView) findViewById(R.id.displayDetails); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mDisplayDetails.setTypeface(tf); @@ -149,10 +193,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe classNameTestItems[4] = "Test5"; classNameTestItems[5] = "Test6"; classNameTestItems[6] = "Test7"; + classNameTestItems[7] = "Test8"; - - String[] displayNames = new String[7]; + String[] displayNames = new String[8]; displayNames[0] = "MemSpeed"; displayNames[1] = "RandMem"; displayNames[2] = "Linaro-Libc-Bench"; @@ -160,6 +204,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe displayNames[4] = "Linaro-Harness"; displayNames[5] = "Linaro-Dhrystone"; displayNames[6] = "Iozone"; + displayNames[7] = "Bonnie++"; listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, displayNames); @@ -172,29 +217,27 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { - - //mSelectedTest = (mListView.getItemAtPosition(i)).toString(); - //mSelectedClassTest = classNameTestItems[i]; - - //Log.i(TAG, "View: "+mListView.getItemAtPosition(i).toString()); - //Log.i(TAG, "IsChecked: " + mListView.isItemChecked(i)); - - if(mListView.isItemChecked(i)) { + if (mListView.isItemChecked(i)) { numberOfCheckedTests++; - }else{ + } else { numberOfCheckedTests--; } } }); + + isShellControl(); + } //********************************************************************************************** + + + //********************************************************************************************** @Override - public void onResume(){ + public void onResume() { super.onResume(); // put your code here... - } //********************************************************************************************** @@ -212,66 +255,52 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe //********************************************************************************************** @Override - public void onClick(View v) - { + public void onClick(View v) { - if(v.getId() == R.id.startButton && numberOfCheckedTests > 0) - { + if (v.getId() == R.id.startButton && numberOfCheckedTests > 0) { isAuto = false; isSelected = true; //mDisplayDetails.setText(mSelectedTest + " is running please wait..."); - if(mSelectedClassTest.equals("Test4")) - { + if (mSelectedClassTest.equals("Test4")) { isTempLogFileNeeded = true; - }else - { + } else { isTempLogFileNeeded = false; } - runTests(); + runTests(Integer.parseInt(mRepeatNumber)); - } - else if(v.getId() == R.id.startButton && numberOfCheckedTests == 0) - { - Toast.makeText(v.getContext(),"Please select test...", + } else if (v.getId() == R.id.startButton && numberOfCheckedTests == 0) { + Toast.makeText(v.getContext(), "Please select test...", Toast.LENGTH_SHORT).show(); - } - else if(v.getId() == R.id.saveButton && testDone==1) - { + } else if (v.getId() == R.id.saveButton && testDone == 1) { saveUIResultToFile(); - } - else if(v.getId() == R.id.saveButton && testDone==0) - { - Toast.makeText(v.getContext(),"No results for save", + } else if (v.getId() == R.id.saveButton && testDone == 0) { + Toast.makeText(v.getContext(), "No results for save", Toast.LENGTH_SHORT).show(); - }else if(v.getId() == R.id.startAutoButton) - { + } else if (v.getId() == R.id.startAutoButton) { isAuto = true; isSelected = false; - runTests(); + runTests(Integer.parseInt(mRepeatNumber)); - }else if(v.getId() == R.id.infoButton) - { - String info = "[RUN TEST]: Run selected tests<br><br> [RUN AUTO]: Run all tests in row and save results to file automatically<br><br> [SAVE]: Save result shown on UI (display)"; + } else if (v.getId() == R.id.infoButton) { + String info = "[RUN TEST]: Run selected tests<br><br> [RUN AUTO]: Run all tests in row and save results to file automatically<br><br> [SAVE]: Save result shown on UI (display)<br><br> [Settings]: Allow to control tests repeatability"; createAlertDialog("Help", info); } } - //********************************************************************************************** @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_main, menu); + getMenuInflater().inflate(R.menu.menu_main, menu); return true; } - //********************************************************************************************** @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -282,14 +311,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { + showTestRepeatNumber(); return true; } return super.onOptionsItemSelected(item); } - private void displayResult(String result) - { + private void displayResult(String result) { mDisplayDetails.setText(result); } //********************************************************************************************** @@ -297,62 +326,56 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe //********************************************************************************************** + //Show info about repeat indicator textview in toolbar + //********************************************************************************************** + public void onRepeatIndicatorClick(View v){ + + int x = (int)v.getX(); + int y = (int)v.getY(); + + Context context = mContext; + CharSequence message = "Repeat indicator"; + int duration = Toast.LENGTH_SHORT; + + final Toast toastTop = Toast.makeText(context, message, duration); + toastTop.setGravity(Gravity.TOP | Gravity.LEFT, x,y); + + toastTop.show(); + } + + + + //********************************************************************************************** //Calculate best text size depends on pixels //********************************************************************************************** - public int getPixels(int pixMin) - { + public int getPixels(int pixMin) { int pixels = 11; - if (pixMin < 401) - { + if (pixMin < 401) { pixels = 12; - } - else if (pixMin < 451) - { + } else if (pixMin < 451) { pixels = 14; - } - else if (pixMin < 501) - { + } else if (pixMin < 501) { pixels = 15; - } - else if (pixMin < 551) - { + } else if (pixMin < 551) { pixels = 16; - } - else if (pixMin < 601) - { + } else if (pixMin < 601) { pixels = 18; - } - else if (pixMin < 651) - { + } else if (pixMin < 651) { pixels = 20; - } - else if (pixMin < 721) - { + } else if (pixMin < 721) { pixels = 22; - } - else if (pixMin < 751) - { + } else if (pixMin < 751) { pixels = 23; - } - else if (pixMin < 801) - { + } else if (pixMin < 801) { pixels = 24; - } - else if (pixMin < 851) - { + } else if (pixMin < 851) { pixels = 26; - } - else if (pixMin < 901) - { + } else if (pixMin < 901) { pixels = 28; - } - else if (pixMin < 951) - { + } else if (pixMin < 951) { pixels = 30; - } - else - { + } else { pixels = 32; } @@ -360,58 +383,57 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe } - //********************************************************************************************** //Save "mDisplayDetails" text to file //********************************************************************************************** - public void saveUIResultToFile(){ + public void saveUIResultToFile() { - File dir = new File (getFilesDir() + "/download"); - dir.mkdirs(); - File file = new File(dir, "testUIData.txt"); + File dir = new File(getFilesDir() + "/download"); + dir.mkdirs(); + File file = new File(dir, "testUIData.txt"); - try { - FileOutputStream f = new FileOutputStream(file); - PrintWriter pw = new PrintWriter(f); - pw.println(mDisplayDetails.getText().toString()); - pw.flush(); - pw.close(); - f.close(); - - Log.i("IVO", getFilesDir() + " FilePath: " + file.getAbsolutePath()); - Toast.makeText(mContext,"Result was saved to file: " + file.getAbsolutePath(), - Toast.LENGTH_LONG).show(); - - } catch (FileNotFoundException e) { - e.printStackTrace(); + try { + FileOutputStream f = new FileOutputStream(file); + PrintWriter pw = new PrintWriter(f); + pw.println(mDisplayDetails.getText().toString()); + pw.flush(); + pw.close(); + f.close(); - } catch (IOException e) { - e.printStackTrace(); - } + Log.i("IVO", getFilesDir() + " FilePath: " + file.getAbsolutePath()); + Toast.makeText(mContext, "Result was saved to file: " + file.getAbsolutePath(), + Toast.LENGTH_LONG).show(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + + } catch (IOException e) { + e.printStackTrace(); + } } //********************************************************************************************** //Save results from Auto tests to text file with random name every time //********************************************************************************************** - public void saveAutoTestResultToFile(){ + public void saveAutoTestResultToFile() { - File dir = new File (getFilesDir() + "/download"); + File dir = new File(getFilesDir() + "/download"); dir.mkdirs(); - autoTestFile = new File(dir, "testLogcatData_"+autoTestFileNameIdentifier+".txt"); + autoTestFile = new File(dir, "testLogcatData_" + autoTestFileNameIdentifier + ".txt"); try { - FileOutputStream f = new FileOutputStream(autoTestFile,true); + FileOutputStream f = new FileOutputStream(autoTestFile, true); PrintWriter pw = new PrintWriter(f); pw.println(mTestResult/*mDisplayDetails.getText().toString()*/); pw.flush(); pw.close(); f.close(); - Log.i("IVO", getFilesDir() + " FilePath: " + autoTestFile.getAbsolutePath()); + Log.i(TAG, getFilesDir() + " FilePath: " + autoTestFile.getAbsolutePath()); //Toast.makeText(mContext,"Result was saved to file: " + file.getAbsolutePath(), - // Toast.LENGTH_LONG).show(); + // Toast.LENGTH_LONG).show(); } catch (FileNotFoundException e) { @@ -427,32 +449,32 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe //********************************************************************************************** //Run tests //********************************************************************************************** - public void runTests() { + public void runTests(int timesToRun) { nextTestIndex = 0; allTestsCount = 0; mAllTests = new ArrayList<String>(); selectedClassTests = new ArrayList<String>(); - mAllTestsResult=""; + mAllTestsResult = ""; selectedClassTests.clear(); mAllTests.clear(); + mDisplayDetails.scrollTo(0, 0); - mDisplayDetails.scrollTo(0,0); + //Show to async task when real end has come + endTestCounter = timesToRun; - if(isAuto) - { + if (isAuto) { for (int i = 0; i < mListView.getCount(); i++) { mAllTests.add((mListView.getItemAtPosition(i)).toString()); } } - if(isSelected) - { + if (isSelected) { for (int i = 0; i < mListView.getCount(); i++) { - if(mListView.isItemChecked(i)) { + if (mListView.isItemChecked(i)) { mAllTests.add((mListView.getItemAtPosition(i)).toString()); selectedClassTests.add(classNameTestItems[i]); } @@ -460,48 +482,52 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe } allTestsCount = mAllTests.size(); - if(isAuto) Log.i(TAG, "autoTest:" + allTestsCount); - if(isSelected) Log.i(TAG, "Selected tests:" + allTestsCount); + if (isAuto) Log.i(TAG, "autoTest:" + allTestsCount); + if (isSelected) Log.i(TAG, "Number of selected tests:" + allTestsCount); + Log.i(TAG, "Repeat tests:" + timesToRun); - if (mAllTests.size() > 0){ + if (mAllTests.size() > 0) { SecureRandom random = new SecureRandom(); autoTestFileNameIdentifier = new BigInteger(11, random).toString(32); + for(int counter = 0; counter < timesToRun; counter++) { + //Clear test index on each repeat + nextTestIndex = 0; - for(int i = 0; i < allTestsCount; i++) { + for (int i = 0; i < allTestsCount; i++) { - isTempLogFileNeeded = false;//make it false for now + isTempLogFileNeeded = false;//make it false for now - if (nextTestIndex < allTestsCount) { + if (nextTestIndex < allTestsCount) { - if (isAuto) { - mSelectedTest = mAllTests.get(nextTestIndex); - mSelectedClassTest = classNameTestItems[nextTestIndex]; - } + if (isAuto) { + mSelectedTest = mAllTests.get(nextTestIndex); + mSelectedClassTest = classNameTestItems[nextTestIndex]; + } - if (isSelected){ - mSelectedTest = mAllTests.get(nextTestIndex).toString(); - mSelectedClassTest = selectedClassTests.get(nextTestIndex).toString(); - } + if (isSelected) { + mSelectedTest = mAllTests.get(nextTestIndex).toString(); + mSelectedClassTest = selectedClassTests.get(nextTestIndex).toString(); + } - String localSelectedTest = mSelectedTest; - String localSelectedClassTest = mSelectedClassTest; + String localSelectedTest = mSelectedTest; + String localSelectedClassTest = mSelectedClassTest; - //if(!localSelectedClassTest.equals("Test4")) { //Test4 is too long so stop it for faster debugging + //if(!localSelectedClassTest.equals("Test4")) { //Test4 is too long so stop it for faster debugging - AsyncTaskRunner runner = new AsyncTaskRunner(localSelectedTest, localSelectedClassTest); - //runner.execute(mSelectedTest); - runner.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, localSelectedTest); - //} - nextTestIndex++; + AsyncTaskRunner runner = new AsyncTaskRunner(localSelectedTest, localSelectedClassTest, counter+1, timesToRun); + //runner.execute(mSelectedTest); + runner.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, localSelectedTest); + //} + nextTestIndex++; + } } } } } - //********************************************************************************************** //Can Use this method when benchmark test take a lot of time and logcat dev/log/main ring buffer is overloaded //Reads only app logs @@ -522,16 +548,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe process = Runtime.getRuntime().exec("logcat -f " + tempLogFile.getAbsolutePath()); - } catch (Exception e1) { - e1.printStackTrace(); + e1.printStackTrace(); } return process; } //********************************************************************************************** - public void createAlertDialog(String title, String message){ + public void createAlertDialog(String title, String message) { AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(title); alertDialog.setMessage(Html.fromHtml(message)); @@ -545,6 +570,292 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe } //********************************************************************************************** + + //********************************************************************************************** + //Show dialog with test repeat number when settings are clicked + //********************************************************************************************** + public void showTestRepeatNumber() { + // get prompts.xml view + LayoutInflater li = LayoutInflater.from(mActivity); + View promptsView = li.inflate(R.layout.prompts, null); + + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( + mActivity); + + // set prompts.xml to alertdialog builder + alertDialogBuilder.setView(promptsView); + + SharedPreferences prefs = getPreferences(MODE_PRIVATE); + final SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); + + mRepeatNumber = prefs.getString(KEY_REPEAT_NUMBER,"1"); + + + final NumberPicker np = (NumberPicker) promptsView.findViewById(R.id.numberPicker1); + np.setMinValue(1); + np.setMaxValue(99); + np.setWrapSelectorWheel(false); + np.setValue(Integer.parseInt(mRepeatNumber)); + + + // set dialog message + alertDialogBuilder + .setCancelable(false) + .setPositiveButton("OK", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // get user input and set it to result + // edit text + //result.setText(userInput.getText()); + if (!mRepeatNumber.equals(np.getValue())) {//if user input not the same as from preferences + mRepeatNumber = Integer.toString(np.getValue()); + editor.putString(KEY_REPEAT_NUMBER, Integer.toString(np.getValue())); + editor.apply(); + + mToolbarRepeatIndicator.setText(" "+mRepeatNumber+" ");//change text in toolbar textview + } + } + }) + .setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); + + // create alert dialog + AlertDialog alertDialog = alertDialogBuilder.create(); + + // show it + alertDialog.show(); + + //Window window = alertDialog.getWindow(); + //window.setLayout(500, 500); + + } + + //********************************************************************************************** + //Check adb shell params + //********************************************************************************************** + public boolean isShellParamsCorrect(String... params) + { + //Check tests are correct + boolean isShellTestFind = false; + String testsFromShell[] = params[0].split(":"); + String repeatShellTests = params[1]; + + //******************Check is tests ok******************* + for (String selected : testsFromShell) { + for (String className : classNameTestItems) { + if (className.equals(selected)) { + //Found it! + isShellTestFind = true; + } + } + + if(isShellTestFind){ //if test is found + + isShellTestFind = false; + }else + { + //Set test as finished and put some info about the error + writeToSocketFile("isFinished", "1"); + writeToSocketFile("info", "Error: [persist.sys.tests] is not set or is set in a wrong way. Please check the script and fix it!"); + return false; + } + } + + //******************Check is repeat number ok******************* + if(repeatShellTests.length() == 0) { + //Set test as finished and put some info about the error + writeToSocketFile("isFinished", "1"); + writeToSocketFile("info", "Error: [persist.sys.repeat] is not set..."); + return false; + }else if(repeatShellTests.length() > 0) { + // Is a number + if(!isNumeric(repeatShellTests)) { + writeToSocketFile("isFinished", "1"); + writeToSocketFile("info", "Error: [persist.sys.repeat] is not numeric string..."); + return false; + } + + if(repeatShellTests.equals("0")) { + writeToSocketFile("isFinished", "1"); + writeToSocketFile("info", "Error: [persist.sys.repeat] is less than 1"); + return false; + } + } + + return true; + } + + + + //********************************************************************************************** + //Run tests in shell control + //********************************************************************************************** + public boolean isShellControl() { + //Log.i(TAG, "isShellControl"); + boolean res = false; + + String control = Util.getProperty("persist.sys.control"); + String testsToBeRun = Util.getProperty("persist.sys.tests"); + String repeatShellTests = Util.getProperty("persist.sys.repeat"); + + res = control.equals("shell"); + + if (res) { + + //clear isFinished.txt + writeToSocketFile("isFinished", "0"); + writeToSocketFile("info", ""); + + + //Let's check the shell parameters + if(!isShellParamsCorrect(testsToBeRun, repeatShellTests)){ + return false; + } + + + + String testsFromShell[] = testsToBeRun.split(":"); + + //if property is not set by the adb shell set it to 1 + if(repeatShellTests.length() == 0) + { + repeatShellTests = "1"; + } + + Log.i(TAG, "control:" + control); + Log.i(TAG, "testToBeRun:" + testsToBeRun); + Log.i(TAG, "repeatShellTests:" + repeatShellTests); + + int mActivePosition = 0; + + mListView.clearChoices(); + listAdapter.notifyDataSetChanged(); + + for (String className : classNameTestItems) { + for (String selected : testsFromShell) { + + if (className.equals(selected)) { + //Click on the current test + mListView.performItemClick( + mListView.getAdapter().getView(mActivePosition, null, null), + mActivePosition, + mListView.getAdapter().getItemId(mActivePosition)); + } + } + mActivePosition++; + } + + isAuto = false; + isSelected = true; + + + runTests(Integer.parseInt(repeatShellTests)); + + } + return res; + } + + //********************************************************************************************** + //Check if string contains only digits + //********************************************************************************************** + public static boolean isNumeric(String str) + { + for (char c : str.toCharArray()) + { + if (!Character.isDigit(c)) return false; + } + return true; + } + + + + //********************************************************************************************** + //Create and write to file used by adb shell + //********************************************************************************************** + public Boolean writeToSocketFile(String fname, String fcontent) { + try { + + File dir = new File(getFilesDir() + "/socket"); + dir.mkdirs(); + + + String fpath = getFilesDir() + "/socket/" + fname + ".txt"; + + File file = new File(fpath); + + // If file does not exists, then create it + if (!file.exists()) { + file.createNewFile(); + } + + FileWriter fw = new FileWriter(file.getAbsoluteFile()); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(fcontent); + bw.close(); + + Log.i("TAG", "Sucess"); + return true; + + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } + + //********************************************************************************************** + //Get device information + //********************************************************************************************** + public static String getInfosAboutDevice(Activity a) { + String s = ""; + try { + PackageInfo pInfo = a.getPackageManager().getPackageInfo( + a.getPackageName(), PackageManager.GET_META_DATA); + s += "\n APP Package Name: " + a.getPackageName(); + s += "\n APP Version Name: " + pInfo.versionName; + s += "\n APP Version Code: " + pInfo.versionCode; + s += "\n"; + } catch (PackageManager.NameNotFoundException e) { + } + s += "\n OS Version: " + System.getProperty("os.version") + " (" + + android.os.Build.VERSION.INCREMENTAL + ")"; + s += "\n OS API Level: " + android.os.Build.VERSION.SDK; + s += "\n Device: " + android.os.Build.DEVICE; + s += "\n Model (and Product): " + android.os.Build.MODEL + " (" + + android.os.Build.PRODUCT + ")"; + // TODO add application version! + + // more from + // http://developer.android.com/reference/android/os/Build.html : + s += "\n Manufacturer: " + android.os.Build.MANUFACTURER; + s += "\n Other TAGS: " + android.os.Build.TAGS; + + s += "\n screenWidth: " + + a.getWindow().getWindowManager().getDefaultDisplay() + .getWidth(); + s += "\n screenHeigth: " + + a.getWindow().getWindowManager().getDefaultDisplay() + .getHeight(); + s += "\n Keyboard available: " + + (a.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); + + s += "\n Trackball available: " + + (a.getResources().getConfiguration().navigation == Configuration.NAVIGATION_TRACKBALL); + s += "\n SD Card state: " + Environment.getExternalStorageState(); + Properties p = System.getProperties(); + Enumeration keys = p.keys(); + String key = ""; + while (keys.hasMoreElements()) { + key = (String) keys.nextElement(); + s += "\n > " + key + " = " + (String) p.get(key); + } + return s; + } + //********************************************************************************************** //Async task for background test processing //********************************************************************************************** @@ -554,19 +865,23 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ProgressDialog progressDialog; String selectedTest; String selectedClassTest; + int stepN; + int repeatN; - public AsyncTaskRunner(String test, String classTest) { + public AsyncTaskRunner(String test, String classTest, int step, int repeat) { super(); selectedTest = test; selectedClassTest = classTest; + stepN = step; + repeatN = repeat; } @Override protected String doInBackground(String... params) { - publishProgress(selectedTest, selectedClassTest); + publishProgress(selectedTest, selectedClassTest, Integer.toString(stepN), Integer.toString(repeatN)); try { @@ -577,12 +892,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe Method thisMethod = thisClass.getMethod("startBenchmark", Integer.TYPE); mTestResult = (String) (thisMethod.invoke(iClass, 1)); - mAllTestsResult = mAllTestsResult +"\n\n"+ mTestResult; + mAllTestsResult = mAllTestsResult + "\n\n" + mTestResult; - if(isAuto) { + if (isAuto) { saveAutoTestResultToFile(); - }else - { + } else { saveAutoTestResultToFile(); } testDone = 1; @@ -605,19 +919,30 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe //displayResult(mTestResult); //UI display Log.i(TAG, mTestResult); //adb logcat display - String endTest=""; - if(isAuto) { + String endTest = ""; + if (isAuto) { endTest = classNameTestItems[allTestsCount - 1]; - }else - { + } else { endTest = selectedClassTests.get(allTestsCount - 1).toString(); } - if(result.equals(endTest)) { //if last one is finished + //decrease the counter if endTest + if (result.equals(endTest)) { + endTestCounter--; + } + + + if (result.equals(endTest) && endTestCounter == 0) { //if last one is finished and counter is 0 + + //Inform shell that tests are done + writeToSocketFile("isFinished", "1"); + + //Set some info to shell about test status...where results are saved + writeToSocketFile("info", "Save result to: " + autoTestFile.getAbsolutePath()); displayResult(mAllTestsResult);//UI display - String filepath = "<font color=\"blue\">"+autoTestFile.getAbsolutePath()+"</font>"; + String filepath = "<font color=\"blue\">" + autoTestFile.getAbsolutePath() + "</font>"; createAlertDialog("File with results created", filepath); } } @@ -629,7 +954,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe Log.i(TAG, "selectedTest:" + selectedTest); //if(isAuto) { - mDisplayDetails.setText(selectedTest + " is running please wait..."); + mDisplayDetails.setText(selectedTest + " is running please wait..."); //} } @@ -641,13 +966,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe String extraText = ""; - if(text[1].equals(("Test4"))) //set some extra text for this test to inform user for longer wait. + if (text[1].equals(("Test4"))) //set some extra text for this test to inform user for longer wait. { extraText = "\n\nNote: This test can take more than 30 min. so be patient..."; } progressDialog = new ProgressDialog(MainActivity.this); - progressDialog.setTitle("ProgressDialog"); + progressDialog.setTitle("Step:" + text[2] + " From:" + text[3]); progressDialog.setMessage(text[0] + " is running please wait..." + extraText); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setCanceledOnTouchOutside(false); @@ -669,17 +994,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe progressDialog.show(); - if(isAuto) { + if (isAuto) { int mActivePosition = 0; mListView.clearChoices(); listAdapter.notifyDataSetChanged(); - for (String className : classNameTestItems) - { - if(className.equals(text[1])) - { + for (String className : classNameTestItems) { + if (className.equals(text[1])) { //Click on the current test mListView.performItemClick( mListView.getAdapter().getView(mActivePosition, null, null), @@ -691,7 +1014,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe } } - //********************************************************************************************** + //********************************************************************************************** }//AsyncTaskRunner //********************************************************************************************** diff --git a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Test8.java b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Test8.java new file mode 100644 index 0000000..f6368da --- /dev/null +++ b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Test8.java @@ -0,0 +1,26 @@ +package org.linaro.iasenov.benchmarkframework; + +/** + * Created by iasenov on 9/2/16. + */ +public class Test8 extends BaseBenchmark { + + public String startBenchmark(int count) { + version = " Bonnie++ "; + benchmarkName = "Test8"; + executable_name = "bonnie"; + + + clear(); + + startTest = System.currentTimeMillis(); + + TESTCOMMANDS = getCommands(executable_name); + + xout[2] = copyAssetsExecFileAndRun(executable_name, TESTCOMMANDS); + + endTest = System.currentTimeMillis(); + + return benchmarkName + ":" + getBenchmarkResult(5); + } +} diff --git a/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Util.java b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Util.java new file mode 100644 index 0000000..7be55f7 --- /dev/null +++ b/BenchmarkFramework/app/src/main/java/org/linaro/iasenov/benchmarkframework/Util.java @@ -0,0 +1,44 @@ +package org.linaro.iasenov.benchmarkframework; + +import android.util.Log; + +import java.lang.reflect.Method; + +/** + * Created by iasenov on 9/2/16. + */ +public class Util { + + static String TAG = "Util"; + + public static void setProperty(String key, String value) { + try { + @SuppressWarnings("rawtypes") + Class SystemProperties = Class.forName("android.os.SystemProperties"); + Method setMethod = SystemProperties.getMethod("set", new Class[]{String.class, String.class}); + setMethod.invoke(SystemProperties, new Object[]{key, value}); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + Log.i(TAG, e.getMessage()); + } + } + + public static String getProperty(String key) { + try { + @SuppressWarnings("rawtypes") + Class SystemProperties = Class.forName("android.os.SystemProperties"); + Method setMethod = SystemProperties.getMethod("get", new Class[]{String.class}); + Object value = setMethod.invoke(SystemProperties, new Object[]{key}); + return (String) value; + } catch (IllegalArgumentException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } +} diff --git a/BenchmarkFramework/app/src/main/res/drawable/benchmark.png b/BenchmarkFramework/app/src/main/res/drawable/benchmark.png Binary files differnew file mode 100644 index 0000000..8fe4b57 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/drawable/benchmark.png diff --git a/BenchmarkFramework/app/src/main/res/drawable/information_1.png b/BenchmarkFramework/app/src/main/res/drawable/information_1.png Binary files differdeleted file mode 100644 index f0e1142..0000000 --- a/BenchmarkFramework/app/src/main/res/drawable/information_1.png +++ /dev/null diff --git a/BenchmarkFramework/app/src/main/res/drawable/relativelayoutshape.xml b/BenchmarkFramework/app/src/main/res/drawable/relativelayoutshape.xml new file mode 100644 index 0000000..2203b82 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/drawable/relativelayoutshape.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> +<corners + android:topLeftRadius="0dp" + android:topRightRadius="0dp" + android:bottomRightRadius="0dp" + android:bottomLeftRadius="0dp"> +</corners> +<stroke + android:width="2dp" + android:color="#20A840"> +</stroke> +<gradient + android:angle="270" + android:startColor="#000000" + android:endColor="#000000"> +</gradient> +</shape> diff --git a/BenchmarkFramework/app/src/main/res/layout/activity_main.xml b/BenchmarkFramework/app/src/main/res/layout/activity_main.xml index fded0e6..6f51b9d 100644 --- a/BenchmarkFramework/app/src/main/res/layout/activity_main.xml +++ b/BenchmarkFramework/app/src/main/res/layout/activity_main.xml @@ -4,39 +4,48 @@ android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="#000000"> + android:background="@drawable/relativelayoutshape"> + + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:orientation="vertical"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:minHeight="?attr/actionBarSize" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:titleTextColor="@android:color/white" + android:background="?attr/colorPrimary"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="#ff0000" + android:textColor="#FFFFFF" + android:layout_gravity="right" + android:onClick="onRepeatIndicatorClick" + android:textStyle="bold" + android:id="@+id/toolbar_repeat_indicator" /> + + </android.support.v7.widget.Toolbar> + + <!-- Layout for content is here. This can be a RelativeLayout --> + + </LinearLayout> + <LinearLayout - android:layout_width="wrap_content" + android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" - android:background="#20A840"> - - <!-- - <Button - android:id="@+id/startButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Run Test"></Button> - <Button - android:id="@+id/startAutoButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Run Auto"></Button> - - <Button - android:id="@+id/saveButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Save"></Button> + android:background="#20A840" + android:layout_marginTop="55dp"> <Button - android:id="@+id/infoButton" - android:layout_width="50dp" - android:layout_height="40dp" - android:background="@drawable/information"></Button> - --> - <Button android:id="@+id/startButton" android:text="RUN TEST" @@ -85,12 +94,14 @@ android:id="@+id/displayDetails" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:layout_marginTop="50dp" + android:layout_marginTop="105dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" android:text="Result ..." android:typeface="monospace" android:maxLines = "20" android:scrollbars = "vertical" - android:textStyle="bold" > + android:textStyle="bold"> </TextView> </LinearLayout> @@ -101,10 +112,14 @@ <ListView android:id="@+id/tests_list_view" - android:layout_marginTop="300dp" + android:layout_marginTop="355dp" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:background="#fff8ce"></ListView> + android:layout_marginLeft="2dp" + android:layout_marginRight="2dp" + android:layout_marginBottom="2dp" + android:background="#fff8ce" + ></ListView> </LinearLayout> diff --git a/BenchmarkFramework/app/src/main/res/layout/prompts.xml b/BenchmarkFramework/app/src/main/res/layout/prompts.xml new file mode 100644 index 0000000..4749e12 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/layout/prompts.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/layout_root" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" + android:padding="10dp"> + + <TextView + android:id="@+id/textView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Repeat number" + android:layout_gravity="center_vertical|center_horizontal" + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <NumberPicker + android:id="@+id/numberPicker1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|center_horizontal" /> + + <!-- + <EditText + android:id="@+id/editTextDialogUserInput" + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <requestFocus /> + + </EditText> + --> + +</LinearLayout> diff --git a/BenchmarkFramework/app/src/main/res/mipmap-hdpi/benchmark.png b/BenchmarkFramework/app/src/main/res/mipmap-hdpi/benchmark.png Binary files differnew file mode 100644 index 0000000..8fe4b57 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/mipmap-hdpi/benchmark.png diff --git a/BenchmarkFramework/app/src/main/res/mipmap-mdpi/benchmark.png b/BenchmarkFramework/app/src/main/res/mipmap-mdpi/benchmark.png Binary files differnew file mode 100644 index 0000000..8fe4b57 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/mipmap-mdpi/benchmark.png diff --git a/BenchmarkFramework/app/src/main/res/mipmap-xhdpi/benchmark.png b/BenchmarkFramework/app/src/main/res/mipmap-xhdpi/benchmark.png Binary files differnew file mode 100644 index 0000000..8fe4b57 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/mipmap-xhdpi/benchmark.png diff --git a/BenchmarkFramework/app/src/main/res/mipmap-xxhdpi/benchmark.png b/BenchmarkFramework/app/src/main/res/mipmap-xxhdpi/benchmark.png Binary files differnew file mode 100644 index 0000000..8fe4b57 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/mipmap-xxhdpi/benchmark.png diff --git a/BenchmarkFramework/app/src/main/res/mipmap-xxxhdpi/benchmark.png b/BenchmarkFramework/app/src/main/res/mipmap-xxxhdpi/benchmark.png Binary files differnew file mode 100644 index 0000000..8fe4b57 --- /dev/null +++ b/BenchmarkFramework/app/src/main/res/mipmap-xxxhdpi/benchmark.png diff --git a/BenchmarkFramework/app/src/main/res/values/colors.xml b/BenchmarkFramework/app/src/main/res/values/colors.xml index 3ab3e9c..048ec8c 100644 --- a/BenchmarkFramework/app/src/main/res/values/colors.xml +++ b/BenchmarkFramework/app/src/main/res/values/colors.xml @@ -3,4 +3,5 @@ <color name="colorPrimary">#3F51B5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#FF4081</color> + <color name="skyBlue">#87CEEB</color> </resources> diff --git a/BenchmarkFramework/app/src/main/res/values/strings.xml b/BenchmarkFramework/app/src/main/res/values/strings.xml index fb91db7..57b5632 100644 --- a/BenchmarkFramework/app/src/main/res/values/strings.xml +++ b/BenchmarkFramework/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ <resources> - <string name="app_name">BenchmarkFramework</string> + <string name="app_name">Benchmark Framework</string> <string name="action_settings">Settings</string> </resources> diff --git a/BenchmarkFramework/app/src/main/res/values/styles.xml b/BenchmarkFramework/app/src/main/res/values/styles.xml index 44f664f..d424e6a 100644 --- a/BenchmarkFramework/app/src/main/res/values/styles.xml +++ b/BenchmarkFramework/app/src/main/res/values/styles.xml @@ -6,6 +6,12 @@ <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> + + <!-- To change the popup menu and app text color --> + <item name="android:textColor">@color/colorPrimary</item> + + <!-- To change the background of options menu--> + <item name="android:itemBackground">@color/skyBlue</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> diff --git a/BenchmarkFramework/shellscript/runTestsFromShell.sh b/BenchmarkFramework/shellscript/runTestsFromShell.sh new file mode 100755 index 0000000..ae35b00 --- /dev/null +++ b/BenchmarkFramework/shellscript/runTestsFromShell.sh @@ -0,0 +1,136 @@ +#!/bin/sh + +# This script run tests from benchmark application using adb shell properties. +# Root access to device is needed + + +# Test1 = "MemSpeed" +# Test2 = "RandMem" +# Test3 = "Linaro-Libc-Bench" +# Test4 = "Linaro-StringBench" +# Test5 = "Linaro-Harness" +# Test6 = "Linaro-Dhrystone" +# Test7 = "Iozone" +# Test8 = "Bonnie++" + + +adb devices +adb wait-for-device root +adb wait-for-device remount + + +GREEN='\033[0;32m' +NC='\033[0m' # No Color +APP_PATH="/home/users/iasenov/Documents/Linaro/BenchmarkTest" + +#**********************************Functions************************ +Wait(){ + while [ $(adb shell cat data/data/org.linaro.iasenov.benchmarkframework/files/socket/isFinished.txt) -ne 1 ] + do + sleep 10 + done + echo "${GREEN}Status info:${NC} $(adb shell cat data/data/org.linaro.iasenov.benchmarkframework/files/socket/info.txt)" + echo "${GREEN}Tests done${NC}" + echo "*****************************************************" +} + +Show(){ + +# REPEAT=$(adb shell getprop persist.sys.repeat) +# +# if [ "$REPEAT"="" ]; then +# echo "$REPEAT" +# adb shell setprop persist.sys.repeat "1" +# fi; + + echo "\n" + echo "*****************************************************" + echo "${GREEN}Use control:${NC} $(adb shell getprop persist.sys.control)" + echo "${GREEN}Running tests:${NC} $(adb shell getprop persist.sys.tests)" + echo "${GREEN}Times to run tests:${NC} $(adb shell getprop persist.sys.repeat)" +} + + +Start(){ + adb shell am start -n org.linaro.iasenov.benchmarkframework/.MainActivity +} + + +Stop(){ + adb shell setprop persist.sys.tests "" + adb shell setprop persist.sys.repeat "" + adb shell am force-stop org.linaro.iasenov.benchmarkframework +} + +kill(){ + adb shell am kill org.linaro.iasenov.benchmarkframework +} + +install_app(){ + echo "\n" + echo "*****************************************************" + echo "${GREEN}Install benchmark application:${NC}" + adb install -r ${APP_PATH}/BenchmarkFramework/app/build/outputs/apk/app-debug.apk + echo "*****************************************************" +} + +#******************************************************************** + +# Install benchmark appliction +install_app + +# Set shell mode for application +adb shell setprop persist.sys.control "shell" + +echo "${GREEN}Benchmarks:${NC}" +echo "" +echo "Test1 = MemSpeed" +echo "Test2 = RandMem" +echo "Test3 = Linaro-Libc-Bench" +echo "Test4 = Linaro-StringBench" +echo "Test5 = Linaro-Harness" +echo "Test6 = Linaro-Dhrystone" +echo "Test7 = Iozone" +echo "Test8 = Bonnie++" +echo "" + + + + +#*************First test******************************* +adb shell setprop persist.sys.tests "Test1:Test2" +adb shell setprop persist.sys.repeat "3" +Show +Start +Wait +Stop +#******************************************************* + + + +#*************Second test******************************* +adb shell setprop persist.sys.tests "Test6" +adb shell setprop persist.sys.repeat "1" +Show +Start +Wait +Stop +#******************************************************* + +#*************Third test******************************* +adb shell setprop persist.sys.tests "Test1:Test5:Test6:Test7:Test8" +adb shell setprop persist.sys.repeat "1" +Show +Start +Wait +Stop +#******************************************************* + + +# Stop shell mode for application +adb shell setprop persist.sys.control "" + + +#Stop application +#kill +#Stop |