Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d2eace9 authored by Ray Essick's avatar Ray Essick Committed by Automerger Merge Worker
Browse files

Merge "WriterTest: remove output file after test completes" am: a6144f5e am:...

Merge "WriterTest: remove output file after test completes" am: a6144f5e am: 4f8ef589 am: 2a4b6db1 am: 9d0d8a22 am: 0212e97e

Change-Id: I01d12a1843eda79ee96d1135006c4ef8b33b29cd
parents 7b0e0f33 0212e97e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -26,5 +26,6 @@
        <option name="native-test-device-path" value="/data/local/tmp" />
        <option name="native-test-device-path" value="/data/local/tmp" />
        <option name="module-name" value="writerTest" />
        <option name="module-name" value="writerTest" />
        <option name="native-test-flag" value="-P /data/local/tmp/WriterTestRes/" />
        <option name="native-test-flag" value="-P /data/local/tmp/WriterTestRes/" />
        <option name="native-test-flag" value="-C true" />
    </test>
    </test>
</configuration>
</configuration>
+2 −2
Original line number Original line Diff line number Diff line
@@ -25,9 +25,9 @@ Download and extract the folder. Push all the files in this folder to /data/loca
adb push WriterTestRes /data/local/tmp/
adb push WriterTestRes /data/local/tmp/
```
```


usage: writerTest -P \<path_to_res_folder\>
usage: writerTest -P \<path_to_res_folder\> -C <remove_output_file>
```
```
adb shell /data/local/tmp/writerTest -P /data/local/tmp/WriterTestRes/
adb shell /data/local/tmp/writerTest -P /data/local/tmp/WriterTestRes/ -C true
```
```
Alternatively, the test can also be run using atest command.
Alternatively, the test can also be run using atest command.


+1 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,7 @@ class WriterTest {
        }
        }
        mBufferInfo.clear();
        mBufferInfo.clear();
        if (mInputStream.is_open()) mInputStream.close();
        if (mInputStream.is_open()) mInputStream.close();
        if (gEnv->cleanUp()) remove(OUTPUT_FILE_NAME);
    }
    }


    void setupWriterType(string writerFormat) {
    void setupWriterType(string writerFormat) {
+15 −4
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@ using namespace std;


class WriterTestEnvironment : public ::testing::Environment {
class WriterTestEnvironment : public ::testing::Environment {
  public:
  public:
    WriterTestEnvironment() : res("/data/local/tmp/") {}
    WriterTestEnvironment() : res("/data/local/tmp/"), deleteOutput(true) {}


    // Parses the command line arguments
    // Parses the command line arguments
    int initFromOptions(int argc, char **argv);
    int initFromOptions(int argc, char **argv);
@@ -34,16 +34,21 @@ class WriterTestEnvironment : public ::testing::Environment {


    const string getRes() const { return res; }
    const string getRes() const { return res; }


    bool cleanUp() const { return deleteOutput; }

  private:
  private:
    string res;
    string res;
    bool deleteOutput;
};
};


int WriterTestEnvironment::initFromOptions(int argc, char **argv) {
int WriterTestEnvironment::initFromOptions(int argc, char **argv) {
    static struct option options[] = {{"res", required_argument, 0, 'P'}, {0, 0, 0, 0}};
    static struct option options[] = {{"res", required_argument, 0, 'P'},
                                      {"cleanUp", optional_argument, 0, 'C'},
                                      {0, 0, 0, 0}};


    while (true) {
    while (true) {
        int index = 0;
        int index = 0;
        int c = getopt_long(argc, argv, "P:", options, &index);
        int c = getopt_long(argc, argv, "P:C:", options, &index);
        if (c == -1) {
        if (c == -1) {
            break;
            break;
        }
        }
@@ -52,6 +57,11 @@ int WriterTestEnvironment::initFromOptions(int argc, char **argv) {
            case 'P':
            case 'P':
                setRes(optarg);
                setRes(optarg);
                break;
                break;
            case 'C':
                if (!strcmp(optarg, "false")) {
                    deleteOutput = false;
                }
                break;
            default:
            default:
                break;
                break;
        }
        }
@@ -62,7 +72,8 @@ int WriterTestEnvironment::initFromOptions(int argc, char **argv) {
                "unrecognized option: %s\n\n"
                "unrecognized option: %s\n\n"
                "usage: %s <gtest options> <test options>\n\n"
                "usage: %s <gtest options> <test options>\n\n"
                "test options are:\n\n"
                "test options are:\n\n"
                "-P, --path: Resource files directory location\n",
                "-P, --path: Resource files directory location\n"
                "-C, default:true. Delete output file after test completes\n",
                argv[optind ?: 1], argv[0]);
                argv[optind ?: 1], argv[0]);
        return 2;
        return 2;
    }
    }