├── .github ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── runAqa.yml │ ├── runAqaConfig.json │ └── testTKG.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── clean.mk ├── compile.mk ├── envSettings.mk ├── examples ├── base │ └── playlist.xml ├── feature │ └── playlist.xml ├── hierarchy │ ├── a1 │ │ └── b1 │ │ │ └── playlist.xml │ ├── a2 │ │ ├── b2 │ │ │ ├── c2 │ │ │ │ └── playlist.xml │ │ │ └── playlist.xml │ │ ├── d2 │ │ │ └── playlist.xml │ │ └── playlist.xml │ └── a3 │ │ ├── b3 │ │ └── playlist.xml │ │ ├── c3 │ │ └── d3 │ │ │ └── playlist.xml │ │ └── f3 │ │ └── playlist.xml ├── jdkVersion │ └── playlist.xml ├── platformRequirements │ └── playlist.xml ├── rerun │ ├── playlist.xml │ └── rerunSub │ │ └── playlist.xml └── sliceAndDice │ └── level │ └── playlist.xml ├── featureSettings.mk ├── makeGen.mk ├── makefile ├── moveDmp.mk ├── openj9Settings.mk ├── resources ├── buildPlatformMap.properties ├── modes.xml ├── ottawa.csv └── playlist.xsd ├── runtest.mk ├── scripts ├── build_test.xml ├── build_tools.xml ├── configure.pl ├── getDependencies.pl ├── getDependencies.xml ├── getFileWithRetry.sh ├── getSHAs.sh ├── getTestenvProperties.sh ├── getUniqueId.pl ├── liveMonitor_countTests │ ├── README.md │ ├── count-java-tests.py │ └── jtreg-monitor.py ├── moveDmp.pl ├── remove_duplicate_tests.py ├── resultsSum.pl ├── testBot │ ├── autoModifier.py │ ├── disable.py │ ├── playlistModifier.py │ └── runAqaArgParse.py └── testTKG │ ├── testRunner.py │ ├── test_base.py │ ├── test_feature.py │ ├── test_hierarchy.py │ ├── test_jdkVersion.py │ ├── test_level.py │ ├── test_platformRequirements.py │ ├── test_rerun.py │ └── utils.py ├── settings.mk ├── src └── org │ ├── openj9 │ └── envInfo │ │ ├── CmdExecutor.java │ │ ├── EnvDetector.java │ │ ├── Info.java │ │ ├── JavaInfo.java │ │ ├── MachineInfo.java │ │ └── Utility.java │ └── testKitGen │ ├── Arguments.java │ ├── BuildList.java │ ├── BuildListGenVisitor.java │ ├── CleanVisitor.java │ ├── Constants.java │ ├── DirectoryVisitor.java │ ├── DirectoryWalker.java │ ├── MainRunner.java │ ├── MkGen.java │ ├── ModesDictionary.java │ ├── ParallelGenVisitor.java │ ├── PlaylistInfo.java │ ├── PlaylistInfoParser.java │ ├── TestCategory.java │ ├── TestDivider.java │ ├── TestGenVisitor.java │ ├── TestInfo.java │ ├── TestInfoParser.java │ ├── TestList.java │ ├── TestTarget.java │ ├── UtilsGen.java │ └── Variation.java └── testEnv.mk /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '45 3 * * 4' 22 | 23 | permissions: 24 | contents: read 25 | 26 | jobs: 27 | analyze: 28 | permissions: 29 | actions: read # for github/codeql-action/init to get workflow details 30 | contents: read # for actions/checkout to fetch code 31 | security-events: write # for github/codeql-action/autobuild to send a status report 32 | name: Analyze 33 | runs-on: ubuntu-latest 34 | 35 | strategy: 36 | fail-fast: false 37 | matrix: 38 | language: [ 'python' ] 39 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 40 | # Learn more: 41 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 42 | 43 | steps: 44 | - name: Checkout repository 45 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 46 | 47 | # Initializes the CodeQL tools for scanning. 48 | - name: Initialize CodeQL 49 | uses: github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17 50 | with: 51 | languages: ${{ matrix.language }} 52 | # If you wish to specify custom queries, you can do so here or in a config file. 53 | # By default, queries listed here will override any specified in a config file. 54 | # Prefix the list here with "+" to use these queries and those in the config file. 55 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 56 | 57 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 58 | # If this step fails, then you should remove it and run the build manually (see below) 59 | - name: Autobuild 60 | uses: github/codeql-action/autobuild@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17 61 | 62 | # ℹ️ Command-line programs to run using the OS shell. 63 | # 📚 https://git.io/JvXDl 64 | 65 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 66 | # and modify them (or add more) to build your code if your project 67 | # uses a compiled language 68 | 69 | #- run: | 70 | # make bootstrap 71 | # make release 72 | 73 | - name: Perform CodeQL Analysis 74 | uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17 75 | -------------------------------------------------------------------------------- /.github/workflows/runAqaConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "workflow_repo": "adoptium/TKG" 3 | } 4 | -------------------------------------------------------------------------------- /.github/workflows/testTKG.yml: -------------------------------------------------------------------------------- 1 | name: "Run TKG Tests" 2 | on: 3 | issue_comment: 4 | types: [created] 5 | permissions: 6 | contents: write 7 | issues: write 8 | pull-requests: write 9 | jobs: 10 | testTKG: 11 | permissions: 12 | contents: write 13 | issues: write 14 | pull-requests: write 15 | runs-on: ubuntu-latest 16 | if: startsWith(github.event.comment.body, 'run tkg-test') 17 | steps: 18 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 19 | with: 20 | ref: refs/pull/${{ github.event.issue.number }}/head 21 | 22 | - name: Set up JDK 23 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 24 | with: 25 | distribution: 'temurin' 26 | java-version: 11 27 | 28 | - name: Create success comment 29 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 30 | with: 31 | github-token: ${{secrets.GITHUB_TOKEN}} 32 | script: | 33 | comment_body = ` 34 | @${{ github.actor }} TKG test build started, workflow Run ID: [${{ GITHUB.RUN_ID }}](${{ GITHUB.SERVER_URL }}/${{ GITHUB.REPOSITORY }}/actions/runs/${{ GITHUB.RUN_ID }}) 35 | `; 36 | github.rest.issues.createComment({ 37 | issue_number: context.issue.number, 38 | owner: context.repo.owner, 39 | repo: context.repo.repo, 40 | body: comment_body 41 | }) 42 | 43 | - name: parse options 44 | env: 45 | COMMENT_BODY: ${{ github.event.comment.body }} 46 | run: | 47 | echo "TKG_TEST_OPTIONS=`echo '${{ env.COMMENT_BODY }}' | sed 's/.*run tkg-test\(.*\)/\1/'`" >> $GITHUB_ENV 48 | 49 | - name: run script 50 | env: 51 | TEST_JDK_HOME: ${{ env.JAVA_HOME }} 52 | TEST_OPTIONS: ${{ env.TKG_TEST_OPTIONS }} 53 | run: | 54 | sudo apt-get install ant-contrib -y 55 | cd scripts/testTKG 56 | python testRunner.py $TEST_OPTIONS 57 | 58 | reportFailure: 59 | runs-on: ubuntu-latest 60 | needs: [testTKG] 61 | if: failure() 62 | steps: 63 | - name: Create comment 64 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 65 | with: 66 | github-token: ${{secrets.GITHUB_TOKEN}} 67 | script: | 68 | comment_body = ` 69 | @${{ github.actor }} Build(s) failed, workflow Run ID: [${{ GITHUB.RUN_ID }}](${{ GITHUB.SERVER_URL }}/${{ GITHUB.REPOSITORY }}/actions/runs/${{ GITHUB.RUN_ID }}) 70 | `; 71 | github.rest.issues.createComment({ 72 | issue_number: context.issue.number, 73 | owner: context.repo.owner, 74 | repo: context.repo.repo, 75 | body: comment_body 76 | }) 77 | 78 | reportCancel: 79 | runs-on: ubuntu-latest 80 | needs: [testTKG] 81 | if: cancelled() 82 | steps: 83 | - name: Create comment 84 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 85 | with: 86 | github-token: ${{secrets.GITHUB_TOKEN}} 87 | script: | 88 | comment_body = ` 89 | @${{ github.actor }} Build(s) cancelled, workflow Run ID: [${{ GITHUB.RUN_ID }}](${{ GITHUB.SERVER_URL }}/${{ GITHUB.REPOSITORY }}/actions/runs/${{ GITHUB.RUN_ID }}) 90 | `; 91 | github.rest.issues.createComment({ 92 | issue_number: context.issue.number, 93 | owner: context.repo.owner, 94 | repo: context.repo.repo, 95 | body: comment_body 96 | }) 97 | 98 | reportSuccess: 99 | runs-on: ubuntu-latest 100 | needs: [testTKG] 101 | if: success() 102 | steps: 103 | - name: Create comment 104 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 105 | with: 106 | github-token: ${{secrets.GITHUB_TOKEN}} 107 | script: | 108 | comment_body = ` 109 | @${{ github.actor }} Build(s) successful, workflow Run ID: [${{ GITHUB.RUN_ID }}](${{ GITHUB.SERVER_URL }}/${{ GITHUB.REPOSITORY }}/actions/runs/${{ GITHUB.RUN_ID }}) 110 | `; 111 | github.rest.issues.createComment({ 112 | issue_number: context.issue.number, 113 | owner: context.repo.owner, 114 | repo: context.repo.repo, 115 | body: comment_body 116 | }) 117 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # https://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # java .class files 14 | *.class 15 | 16 | # misc auto generated folders 17 | lib 18 | bin 19 | output_* 20 | resources/TRSS 21 | scripts/testBot/__pycache__ 22 | scripts/testTKG/__pycache__ 23 | 24 | # misc auto generated files 25 | autoGen.mk 26 | utils.mk 27 | rerun.mk 28 | parallelList.mk 29 | *.log 30 | *.tap 31 | machineConfigure.mk 32 | tempTestTargetResult 33 | failedtargets.mk 34 | autoGenEnv.mk 35 | buildInfo.mk 36 | SHAs.txt 37 | 38 | .DS_Store 39 | 40 | /.project 41 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Community Code of Conduct 2 | 3 | **Version 1.1 4 | October 21, 2019** 5 | 6 | ## Our Pledge 7 | 8 | In the interest of fostering an open and welcoming environment, we as 9 | contributors and maintainers pledge to make participation in our project and 10 | our community a harassment-free experience for everyone, regardless of age, body 11 | size, disability, ethnicity, sex characteristics, gender identity and expression, 12 | level of experience, education, socio-economic status, nationality, personal 13 | appearance, race, religion, or sexual identity and orientation. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to creating a positive environment 18 | include: 19 | 20 | * Using welcoming and inclusive language 21 | * Being respectful of differing viewpoints and experiences 22 | * Gracefully accepting constructive criticism 23 | * Focusing on what is best for the community 24 | * Showing empathy towards other community members 25 | 26 | Examples of unacceptable behavior by participants include: 27 | 28 | * The use of sexualized language or imagery and unwelcome sexual attention or 29 | advances 30 | * Trolling, insulting/derogatory comments, and personal or political attacks 31 | * Public or private harassment 32 | * Publishing others' private information, such as a physical or electronic 33 | address, without explicit permission 34 | * Other conduct which could reasonably be considered inappropriate in a 35 | professional setting 36 | 37 | ## Our Responsibilities 38 | 39 | Project maintainers are responsible for clarifying the standards of acceptable 40 | behavior and are expected to take appropriate and fair corrective action in 41 | response to any instances of unacceptable behavior. 42 | 43 | Project maintainers have the right and responsibility to remove, edit, or 44 | reject comments, commits, code, wiki edits, issues, and other contributions 45 | that are not aligned to this Code of Conduct, or to ban temporarily or 46 | permanently any contributor for other behaviors that they deem inappropriate, 47 | threatening, offensive, or harmful. 48 | 49 | ## Scope 50 | 51 | This Code of Conduct applies within all project spaces, and it also applies when 52 | an individual is representing the project or its community in public spaces. 53 | Examples of representing a project or community include using an official 54 | project e-mail address, posting via an official social media account, or acting 55 | as an appointed representative at an online or offline event. Representation of 56 | a project may be further defined and clarified by project maintainers. 57 | 58 | ## Enforcement 59 | 60 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 61 | reported by contacting the project team at codeofconduct@eclipse.org. All 62 | complaints will be reviewed and investigated and will result in a response that 63 | is deemed necessary and appropriate to the circumstances. The project team is 64 | obligated to maintain confidentiality with regard to the reporter of an incident. 65 | Further details of specific enforcement policies may be posted separately. 66 | 67 | Project maintainers who do not follow or enforce the Code of Conduct in good 68 | faith may face temporary or permanent repercussions as determined by other 69 | members of the project's leadership. 70 | 71 | ## Attribution 72 | 73 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 74 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 75 | 76 | [homepage]: https://www.contributor-covenant.org 77 | 78 | For answers to common questions about this code of conduct, see 79 | https://www.contributor-covenant.org/faq 80 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to TKG 2 | 3 | Thanks for your interest in this project. 4 | 5 | ## Project description 6 | 7 | TKG is a project that contains a lightweight harness that assists in 8 | standardizing a diverse set of tests to assist in CI automation. 9 | 10 | * https://github.com/adoptium/TKG 11 | 12 | ## Developer resources 13 | 14 | The project maintains the following source code repositories 15 | 16 | * https://github.com/adoptium/TKG 17 | 18 | ## Eclipse Contributor Agreement 19 | 20 | Before your contribution can be accepted by the project team contributors must 21 | electronically sign the Eclipse Contributor Agreement (ECA). 22 | 23 | * http://www.eclipse.org/legal/ECA.php 24 | 25 | Commits that are provided by non-committers must have a Signed-off-by field in 26 | the footer indicating that the author is aware of the terms by which the 27 | contribution has been provided to the project. The non-committer must 28 | additionally have an Eclipse Foundation account and must have a signed Eclipse 29 | Contributor Agreement (ECA) on file. 30 | 31 | For more information, please see the Eclipse Committer Handbook: 32 | https://www.eclipse.org/projects/handbook/#resources-commit 33 | 34 | ## Contact 35 | 36 | Contact the Eclipse Foundation Webdev team via webdev@eclipse-foundation.org. 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TKG 2 | 3 | TestKitGen (TKG) is a lightweight test harness for bringing together a diverse set of tests or commands under some common behaviour. All testing that runs at the AdoptOpenJDK project is run using TKG to yoke together many types of testing (that run on a variety of test frameworks). 4 | 5 | TKG standardizes: 6 | - test target generation (generates make targets based on contents of playlist.xml files) 7 | - test output, defaulting to Test Anything Protocol (TAP) as the simplest, lowest common denominator 8 | - the way tests are tagged, grouped, included and excluded (categorizing by elements in the playlist file, by group, impl, version, etc) 9 | -------------------------------------------------------------------------------- /clean.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | .DEFAULT_GOAL := clean 16 | 17 | D = / 18 | 19 | ifndef TEST_ROOT 20 | TEST_ROOT := $(shell pwd)$(D).. 21 | endif 22 | 23 | include settings.mk 24 | 25 | cleanBuild: 26 | $(RM) -r $(BUILD_ROOT) 27 | 28 | clean: cleanBuild 29 | $(RM) -r $(Q)$(TEST_ROOT)$(Q)$(D)TKG$(D)output_* 30 | $(RM) $(FAILEDTARGETS) 31 | ant -f $(Q)$(TEST_ROOT)$(Q)$(D)TKG$(D)scripts/build_tools.xml clean 32 | 33 | .PHONY: cleanBuild clean 34 | -------------------------------------------------------------------------------- /compile.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | .DEFAULT_GOAL := compile 16 | 17 | D = / 18 | 19 | ifndef TEST_ROOT 20 | TEST_ROOT := $(shell pwd)$(D).. 21 | endif 22 | 23 | include settings.mk 24 | include moveDmp.mk 25 | -include buildInfo.mk 26 | 27 | ####################################### 28 | # compile all tests under $(TEST_ROOT) 29 | ####################################### 30 | ifneq ($(DYNAMIC_COMPILE), true) 31 | COMPILE_BUILD_LIST := ${BUILD_LIST} 32 | else 33 | COMPILE_BUILD_LIST := ${REFINED_BUILD_LIST} 34 | endif 35 | # TEST_FLAG can be empty, Windows ant does not like empty -D values 36 | ifneq ($(TEST_FLAG),) 37 | TEST_FLAG_PARAM := -DTEST_FLAG=$(TEST_FLAG) 38 | else 39 | TEST_FLAG_PARAM := 40 | endif 41 | COMPILE_CMD=ant -f scripts$(D)build_test.xml $(Q)-DTEST_ROOT=$(TEST_ROOT)$(Q) $(Q)-DBUILD_ROOT=$(BUILD_ROOT)$(Q) $(Q)-DJDK_VERSION=$(JDK_VERSION)$(Q) $(Q)-DJDK_IMPL=$(JDK_IMPL)$(Q) $(Q)-DJDK_VENDOR=$(JDK_VENDOR)$(Q) $(Q)-DJCL_VERSION=$(JCL_VERSION)$(Q) $(Q)-DBUILD_LIST=${COMPILE_BUILD_LIST}$(Q) $(Q)-DRESOURCES_DIR=${RESOURCES_DIR}$(Q) $(Q)-DSPEC=${SPEC}$(Q) $(Q)-DTEST_JDK_HOME=${TEST_JDK_HOME}$(Q) $(Q)-DJVM_VERSION=$(JVM_VERSION)$(Q) $(Q)-DLIB_DIR=$(LIB_DIR)$(Q) ${TEST_FLAG_PARAM} 42 | 43 | 44 | compile: 45 | $(RM) -r $(COMPILATION_OUTPUT); \ 46 | $(MKTREE) $(COMPILATION_OUTPUT); \ 47 | ($(COMPILE_CMD) 2>&1; echo $$? ) | tee $(Q)$(COMPILATION_LOG)$(Q); \ 48 | $(MOVE_TDUMP) 49 | @$(ECHO_NEWLINE) 50 | @$(ECHO_NEWLINE) 51 | @$(ECHO) $(Q)RECORD TEST REPOs SHA $(Q) 52 | $(CD) $(Q)$(TEST_ROOT)$(D)TKG$(D)scripts$(Q); \ 53 | bash $(Q)getSHAs.sh$(Q) --test_root_dir $(Q)$(TEST_ROOT)$(Q) --shas_file $(Q)$(TEST_ROOT)$(D)TKG$(D)SHAs.txt$(Q) 54 | 55 | .PHONY: compile 56 | -------------------------------------------------------------------------------- /envSettings.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | # 16 | # Makefile to compare auto detect values with setting values 17 | # 18 | 19 | -include autoGenEnv.mk 20 | 21 | HOTSPOT_IMPLS=$(or hotspot,sap) 22 | 23 | ifneq ($(AUTO_DETECT), false) 24 | export SPEC:=$(DETECTED_SPEC) 25 | 26 | export MICROARCH:=$(DETECTED_MICRO_ARCH) 27 | 28 | export OS_LABEL:=$(DETECTED_OS_LABEL) 29 | 30 | ifndef JDK_VERSION 31 | export JDK_VERSION:=$(DETECTED_JDK_VERSION) 32 | else 33 | ifneq ($(JDK_VERSION), $(DETECTED_JDK_VERSION)) 34 | $(error DETECTED_JDK_VERSION value is $(DETECTED_JDK_VERSION), settled JDK_VERSION value is $(JDK_VERSION). JDK_VERSION value does not match. Please reset or unset JDK_VERSION) 35 | endif 36 | endif 37 | 38 | ifndef JDK_IMPL 39 | export JDK_IMPL:=$(DETECTED_JDK_IMPL) 40 | else 41 | ifneq ($(JDK_IMPL), $(DETECTED_JDK_IMPL)) 42 | ifneq ($(JDK_IMPL), sap) 43 | $(error DETECTED_JDK_IMPL value is $(DETECTED_JDK_IMPL), settled JDK_IMPL value is $(JDK_IMPL). JDK_IMPL value does not match. Please reset or unset JDK_IMPL) 44 | endif 45 | endif 46 | endif 47 | 48 | ifndef JDK_VENDOR 49 | export JDK_VENDOR:=$(DETECTED_JDK_VENDOR) 50 | else 51 | ifneq ($(JDK_VENDOR), $(DETECTED_JDK_VENDOR)) 52 | $(error DETECTED_JDK_VENDOR value is $(DETECTED_JDK_VENDOR), settled JDK_VENDOR value is $(JDK_VENDOR). JDK_VENDOR value does not match. Please reset or unset JDK_VENDOR) 53 | endif 54 | endif 55 | 56 | export TEST_FLAG:=$(DETECTED_TEST_FLAG) 57 | 58 | else 59 | $(info AUTO_DETECT is set to false) 60 | ifndef SPEC 61 | export SPEC:=$(DETECTED_SPEC) 62 | $(info Warning: No SPEC has been exported. Use auto detected SPEC=$(SPEC).) 63 | endif 64 | ifndef MICROARCH 65 | export MICROARCH:=$(DETECTED_MICROARCH) 66 | $(info Warning: No MICROARCH has been exported. Use auto detected MICROARCH=$(MICROARCH).) 67 | endif 68 | ifndef OS_LABEL 69 | export OS_LABEL:=$(DETECTED_OS_LABEL) 70 | $(info Warning: No OS_LABEL has been exported. Use auto detected OS_LABEL=$(OS_LABEL).) 71 | endif 72 | ifndef JDK_VERSION 73 | export JDK_VERSION:=$(DETECTED_JDK_VERSION) 74 | $(info Warning: No JDK_VERSION has been exported. Use auto detected JDK_VERSION=$(JDK_VERSION).) 75 | endif 76 | ifndef JDK_IMPL 77 | export JDK_IMPL:=$(DETECTED_JDK_IMPL) 78 | $(info Warning: No JDK_IMPL has been exported. Use auto detected JDK_IMPL=$(JDK_IMPL).) 79 | endif 80 | ifndef JDK_VENDOR 81 | export JDK_VENDOR:=$(DETECTED_JDK_VENDOR) 82 | $(info Warning: No JDK_VENDOR has been exported. Use auto detected JDK_VENDOR=$(JDK_VENDOR).) 83 | endif 84 | endif 85 | 86 | export MALLOCOPTIONS= -------------------------------------------------------------------------------- /examples/base/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | testSuccess 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | 23 | testFail 24 | echo "fail"; fail; \ 25 | $(TEST_STATUS) 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/feature/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | testFeatureFips 18 | echo "match FIPS140_3_20220501 and everything else by default"; \ 19 | $(TEST_STATUS) 20 | 21 | FIPS140_3_20220501:applicable 22 | 23 | 24 | 25 | 26 | testFeatureFipsNoApplicable 27 | echo "test excluded on FIPS140_2"; \ 28 | $(TEST_STATUS) 29 | 30 | FIPS140_2:nonapplicable 31 | 32 | 33 | 34 | 35 | testFeatureFipsRequired 36 | echo "only run on FIPS140_3_20220101"; \ 37 | $(TEST_STATUS) 38 | 39 | FIPS140_3_20220101:required 40 | 41 | 42 | 43 | 44 | testFeatureFipsRegexRequired 45 | echo "only run on FIPS140_3 from 2022 Dec 01 to 2029 Dec 31"; \ 46 | $(TEST_STATUS) 47 | 48 | /FIPS140_3_(2022(12\d(2))|202[3-9]\d{4})/:required 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/hierarchy/a1/b1/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a1_b1 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a2/b2/c2/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a2_b2_c2 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a2/b2/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a2_b2 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a2/d2/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a2_d2 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a2/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a2 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a3/b3/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a3_b3 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a3/c3/d3/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a3_b3_c3_d3 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/hierarchy/a3/f3/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_a3_f3 18 | echo "success"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/jdkVersion/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_ver_11 18 | echo "test for version 11"; \ 19 | $(TEST_STATUS) 20 | 21 | 11 22 | 23 | 24 | 25 | 26 | test_ver_17plus 27 | echo "test for version 17+"; \ 28 | $(TEST_STATUS) 29 | 30 | 17+ 31 | 32 | 33 | 34 | 35 | test_ver_8to11 36 | echo "test for version 8 to 11"; \ 37 | $(TEST_STATUS) 38 | 39 | [8, 11] 40 | 41 | 42 | 43 | 44 | test_ver_8to11and17plus 45 | echo "test for version 8 to 11 and 17+"; \ 46 | $(TEST_STATUS) 47 | 48 | [8, 11] 49 | 17+ 50 | 51 | 52 | 53 | 54 | test_disable_ver_11 55 | 56 | 57 | disable version 11 58 | 11 59 | 60 | 61 | echo "disable test for version 11"; \ 62 | $(TEST_STATUS) 63 | 64 | 65 | 66 | test_disable_ver_11to17 67 | 68 | 69 | disable version 11 to 17 70 | [11, 17] 71 | 72 | 73 | echo "disable test for version 11 to 17"; \ 74 | $(TEST_STATUS) 75 | 76 | 77 | 78 | test_disable_ver_8and17plus 79 | 80 | 81 | disable version 8 82 | 8 83 | 84 | 85 | disable version 11 86 | 17+ 87 | 88 | 89 | echo "disable test for version 8 and 17+"; \ 90 | $(TEST_STATUS) 91 | 92 | 93 | -------------------------------------------------------------------------------- /examples/platformRequirements/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | test_arch_x86 18 | echo "test arch.x86"; \ 19 | $(TEST_STATUS) 20 | arch.x86 21 | 22 | 23 | 24 | test_arch_x86_390 25 | echo "test arch.x86 or arch.390"; \ 26 | $(TEST_STATUS) 27 | 28 | arch.x86 29 | arch.390 30 | 31 | 32 | 33 | test_arch_nonx86 34 | echo "test ^arch.x86"; \ 35 | $(TEST_STATUS) 36 | 37 | ^arch.x86 38 | 39 | 40 | 41 | 42 | test_bits_64 43 | echo "test bits.64"; \ 44 | $(TEST_STATUS) 45 | bits.64 46 | 47 | 48 | 49 | test_os_osx 50 | echo "test os.osx"; \ 51 | $(TEST_STATUS) 52 | os.osx 53 | 54 | 55 | 56 | test_osx_x86-64 57 | echo "test osx_x86-64"; \ 58 | $(TEST_STATUS) 59 | os.osx,bits.64,arch.x86 60 | 61 | 62 | 63 | test_not_linux_arch_x86 64 | echo "test on none linux and on arch x86"; \ 65 | $(TEST_STATUS) 66 | ^os.linux,arch.x86 67 | 68 | 69 | 70 | test_osx_x86-64_win_x86_aix_ppc-64 71 | echo "test osx_x86-64 or win_x86 or aix_ppc-64"; \ 72 | $(TEST_STATUS) 73 | 74 | os.osx,bits.64,arch.x86 75 | os.win,bits.32,arch.x86 76 | os.aix,arch.ppc,bits.64 77 | 78 | 79 | 80 | 81 | test_os_linux_ubuntu20plus 82 | echo "test os.linux.ubuntu.20+"; \ 83 | $(TEST_STATUS) 84 | os.linux.ubuntu.20+ 85 | 86 | 87 | 88 | test_os_linux_ubuntu22 89 | echo "test os.linux.ubuntu.22"; \ 90 | $(TEST_STATUS) 91 | os.linux.ubuntu.22 92 | 93 | 94 | 95 | test_os_linux_ubuntu20plus_rhel8plus 96 | echo "test os.linux.ubuntu.20+ or os.linux.rhel.8+"; \ 97 | $(TEST_STATUS) 98 | 99 | os.linux.ubuntu.20+ 100 | os.linux.rhel.8+ 101 | 102 | 103 | 104 | 105 | test_not_os_linux_ubuntu20plus 106 | echo "test on none os.linux.ubuntu.20+"; \ 107 | $(TEST_STATUS) 108 | ^os.linux.ubuntu.20+ 109 | 110 | 111 | test_not_arch_390 112 | echo "test on none arch.390"; \ 113 | $(TEST_STATUS) 114 | ^arch.390 115 | 116 | 117 | 118 | test_arch_x86_skylake 119 | echo "test arch.x86.skylake"; \ 120 | $(TEST_STATUS) 121 | 122 | arch.x86.skylake 123 | 124 | 125 | 126 | 127 | test_arch_390_z15plus 128 | echo "test arch.390.z15+"; \ 129 | $(TEST_STATUS) 130 | 131 | arch.390.z15+ 132 | 133 | 134 | 135 | 136 | test_arch_390_z15 137 | echo "test arch.390.z15"; \ 138 | $(TEST_STATUS) 139 | 140 | arch.390.z15 141 | 142 | 143 | 144 | test_arch_390_z14plus 145 | echo "test arch.390.z14+"; \ 146 | $(TEST_STATUS) 147 | 148 | arch.390.z14+ 149 | 150 | 151 | 152 | 153 | test_not_arch_390_z15plus 154 | echo "test not arch.390.z15+"; \ 155 | $(TEST_STATUS) 156 | 157 | ^arch.390.z15+ 158 | 159 | 160 | 161 | 162 | test_arch_390_z14 163 | echo "test arch.390.z14"; \ 164 | $(TEST_STATUS) 165 | 166 | arch.390.z14 167 | 168 | 169 | 170 | 171 | test_arch_390_z13plus 172 | echo "test arch.390.z13+"; \ 173 | $(TEST_STATUS) 174 | 175 | arch.390.z13+ 176 | 177 | 178 | 179 | 180 | test_arch_390_z13 181 | echo "test arch.390.z13"; \ 182 | $(TEST_STATUS) 183 | 184 | arch.390.z13 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /examples/rerun/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | testRerun 18 | echo "test rerun"; \ 19 | $(TEST_STATUS) 20 | true 21 | 22 | 23 | 24 | testDefault 25 | echo "test default rerun"; \ 26 | $(TEST_STATUS) 27 | 28 | 29 | 30 | 31 | testIgnoreOnRerun 32 | echo "test ignore on rerun"; \ 33 | $(TEST_STATUS) 34 | false 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/rerun/rerunSub/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | testRerunSubDir 18 | echo "test rerun in sub dir"; \ 19 | $(TEST_STATUS) 20 | true 21 | 22 | 23 | 24 | testDefaultSubDir 25 | echo "test default rerun in sub dir"; \ 26 | $(TEST_STATUS) 27 | 28 | 29 | 30 | 31 | testIgnoreOnRerunSubDir 32 | 33 | NoOptions 34 | -Xmx1024m 35 | 36 | echo "test ignore on rerun in sub dir"; \ 37 | $(TEST_STATUS) 38 | false 39 | 40 | system 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/sliceAndDice/level/playlist.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | testDefault 18 | echo "default is extended"; \ 19 | $(TEST_STATUS) 20 | 21 | 22 | 23 | testSanity 24 | echo "sanity"; \ 25 | $(TEST_STATUS) 26 | 27 | sanity 28 | 29 | 30 | 31 | 32 | testExtended 33 | echo "extended"; \ 34 | $(TEST_STATUS) 35 | 36 | extended 37 | 38 | 39 | 40 | 41 | testDev 42 | echo "dev"; \ 43 | $(TEST_STATUS) 44 | 45 | dev 46 | 47 | 48 | 49 | 50 | testSpecial 51 | echo "special"; \ 52 | $(TEST_STATUS) 53 | 54 | special 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /featureSettings.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | ifndef TKG_ITERATIONS 16 | export TKG_ITERATIONS=1 17 | endif 18 | 19 | ifneq (,$(findstring AOT,$(TEST_FLAG))) 20 | export TR_silentEnv=1 21 | export TR_Options=forceAOT 22 | export TR_OptionsAOT=forceAOT 23 | AOT_OPTIONS = -Xshareclasses:name=test_aot -Xscmx400M -Xscmaxaot256m 24 | ifndef AOT_ITERATIONS 25 | export AOT_ITERATIONS=2 26 | endif 27 | endif 28 | -------------------------------------------------------------------------------- /makeGen.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | .PHONY: autoconfig autogen clean help 16 | 17 | .DEFAULT_GOAL := autogen 18 | 19 | help: 20 | @echo "This makefile is used to run perl script which generates makefiles for JVM tests before being built and executed." 21 | @echo "OPTS=help Display help information for more options." 22 | 23 | CURRENT_DIR := $(shell pwd) 24 | OPTS= 25 | 26 | D=/ 27 | P=: 28 | Q=" 29 | 30 | TKG_JAR = .$(D)bin$(D)TestKitGen.jar 31 | JSON_SIMPLE = $(LIB_DIR)$(D)json-simple.jar 32 | 33 | ifneq (,$(findstring Win,$(OS))) 34 | CURRENT_DIR := $(subst \,/,$(CURRENT_DIR)) 35 | P=; 36 | endif 37 | include $(CURRENT_DIR)$(D)featureSettings.mk 38 | -include $(CURRENT_DIR)$(D)autoGenEnv.mk 39 | include $(CURRENT_DIR)$(D)envSettings.mk 40 | 41 | autoconfig: 42 | perl scripts$(D)configure.pl 43 | 44 | autogen: autoconfig 45 | ${TEST_JDK_HOME}/bin/java -cp $(Q)$(TKG_JAR)$(P)$(JSON_SIMPLE)$(Q) org.testKitGen.MainRunner --mode=$(MODE) --spec=$(SPEC) --microArch=$(Q)$(MICROARCH)$(Q) --osLabel=$(Q)$(OS_LABEL)$(Q) --jdkVersion=$(JDK_VERSION) --impl=$(JDK_IMPL) --vendor=$(Q)$(JDK_VENDOR)$(Q) --buildList=${BUILD_LIST} --iterations=$(TKG_ITERATIONS) --aotIterations=$(AOT_ITERATIONS) --testFlag=$(TEST_FLAG) --testTarget=$(TESTTARGET) --testList=$(TESTLIST) --numOfMachines=$(NUM_MACHINES) --testTime=$(TEST_TIME) --TRSSURL=$(TRSS_URL) $(OPTS) 46 | 47 | AUTOGEN_FILES = $(wildcard $(CURRENT_DIR)$(D)jvmTest.mk) 48 | AUTOGEN_FILES += $(wildcard $(CURRENT_DIR)$(D)machineConfigure.mk) 49 | AUTOGEN_FILES += $(wildcard $(CURRENT_DIR)$(D)..$(D)*$(D)autoGenTest.mk) 50 | 51 | clean: 52 | ${TEST_JDK_HOME}/bin/java -cp $(Q)$(TKG_JAR)$(P)$(JSON_SIMPLE)$(Q) org.testKitGen.MainRunner --mode=$(MODE) 53 | 54 | .PHONY: autoconfig autogen clean 55 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https:$(D)$(D)www.apache.org$(D)licenses$(D)LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | # 16 | # Makefile to run various JVM tests 17 | # 18 | 19 | ifndef TEST_JDK_HOME 20 | $(error Please provide TEST_JDK_HOME value.) 21 | else 22 | export TEST_JDK_HOME:=$(subst \,/,$(TEST_JDK_HOME)) 23 | export OLD_JAVA_HOME := $(JAVA_HOME) 24 | export JAVA_HOME := $(TEST_JDK_HOME) 25 | $(info JAVA_HOME is set to $(JAVA_HOME)) 26 | endif 27 | 28 | D = / 29 | MKTREE = mkdir -p 30 | SUBDIRS = .. 31 | 32 | ifndef TEST_ROOT 33 | TEST_ROOT := $(shell pwd)$(D).. 34 | endif 35 | ifndef LIB_DIR 36 | LIB_DIR:=$(TEST_ROOT)$(D)TKG$(D)lib 37 | endif 38 | 39 | UNAME := uname 40 | UNAME_OS := $(shell $(UNAME) -s | cut -f1 -d_) 41 | ifeq ($(findstring CYGWIN,$(UNAME_OS)), CYGWIN) 42 | LIB_DIR:=$(shell cygpath -w $(LIB_DIR)) 43 | endif 44 | 45 | export LIB_DIR:=$(subst \,/,$(LIB_DIR)) 46 | $(info LIB_DIR is set to $(LIB_DIR)) 47 | 48 | _TESTTARGET = $(firstword $(MAKECMDGOALS)) 49 | TESTTARGET = $(patsubst _%,%,$(_TESTTARGET)) 50 | 51 | ####################################### 52 | # run test 53 | ####################################### 54 | ifneq (compile, $(_TESTTARGET)) 55 | ifneq (clean, $(_TESTTARGET)) 56 | ifneq (test, $(_TESTTARGET)) 57 | ifneq (genParallelList, $(_TESTTARGET)) 58 | ifneq (_failed, $(_TESTTARGET)) 59 | ifneq ($(DYNAMIC_COMPILE), true) 60 | $(_TESTTARGET): 61 | $(MAKE) -f makeGen.mk AUTO_DETECT=$(AUTO_DETECT) MODE=tests TESTTARGET=$(TESTTARGET) TESTLIST=$(TESTLIST) 62 | $(MAKE) -f runtest.mk $(_TESTTARGET) 63 | else 64 | $(_TESTTARGET): compile 65 | $(MAKE) -f makeGen.mk AUTO_DETECT=$(AUTO_DETECT) MODE=tests TESTTARGET=$(TESTTARGET) TESTLIST=$(TESTLIST) 66 | $(MAKE) -f runtest.mk $(_TESTTARGET) 67 | endif 68 | endif 69 | endif 70 | endif 71 | endif 72 | endif 73 | 74 | ####################################### 75 | # compile test materials 76 | ####################################### 77 | compile: buildListGen 78 | $(MAKE) -f clean.mk cleanBuild 79 | $(MAKE) -f compile.mk compile 80 | 81 | ####################################### 82 | # If AUTO_DETECT is turned on, compile and execute envDetector in build_envInfo.xml. 83 | ####################################### 84 | envDetect: compileTools 85 | ${TEST_JDK_HOME}$(D)bin$(D)java -cp .$(D)bin$(D)TestKitGen.jar org.openj9.envInfo.EnvDetector 86 | 87 | ####################################### 88 | # Generate refined BUILD_LIST. 89 | ####################################### 90 | buildListGen: envDetect 91 | ifeq ($(DYNAMIC_COMPILE), true) 92 | $(MAKE) -f makeGen.mk AUTO_DETECT=$(AUTO_DETECT) MODE=buildList TESTTARGET=$(TESTTARGET) TESTLIST=$(TESTLIST) 93 | endif 94 | 95 | .PHONY: buildListGen 96 | 97 | .NOTPARALLEL: buildListGen 98 | 99 | ####################################### 100 | # compile tools 101 | ####################################### 102 | include moveDmp.mk 103 | COMPILE_TOOLS_CMD=ant -f .$(D)scripts$(D)build_tools.xml $(Q)-DTEST_JDK_HOME=$(TEST_JDK_HOME)$(Q) $(Q)-DTEST_ROOT=$(TEST_ROOT)$(Q) $(Q)-DLIB_DIR=$(LIB_DIR)$(Q) 104 | 105 | compileTools: 106 | $(RM) -r $(COMPILATION_OUTPUT); \ 107 | $(MKTREE) $(COMPILATION_OUTPUT); \ 108 | ($(COMPILE_TOOLS_CMD) 2>&1; echo $$? ) | tee $(Q)$(COMPILATION_LOG)$(Q); \ 109 | $(MOVE_TDUMP) 110 | 111 | ####################################### 112 | # compile and run all tests 113 | ####################################### 114 | test: compile _all 115 | @$(ECHO) "All Tests Completed" 116 | 117 | .PHONY: test 118 | 119 | .NOTPARALLEL: test 120 | 121 | ####################################### 122 | # run failed tests 123 | ####################################### 124 | _failed: 125 | @$(MAKE) -f failedtargets.mk _failed 126 | 127 | .PHONY: _failed 128 | 129 | .NOTPARALLEL: _failed 130 | 131 | ####################################### 132 | # generate parallel list 133 | ####################################### 134 | genParallelList: envDetect 135 | $(MAKE) -f makeGen.mk AUTO_DETECT=$(AUTO_DETECT) MODE=parallelList NUM_MACHINES=$(NUM_MACHINES) TEST_TIME=$(TEST_TIME) TESTTARGET=$(TEST) TESTLIST=$(TESTLIST) TRSS_URL=$(TRSS_URL) LIB_DIR=$(LIB_DIR) 136 | 137 | ####################################### 138 | # clean 139 | ####################################### 140 | clean: envDetect 141 | $(MAKE) -f makeGen.mk MODE=clean 142 | $(MAKE) -f clean.mk clean 143 | 144 | .PHONY: clean 145 | -------------------------------------------------------------------------------- /moveDmp.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | D = / 16 | Q = " 17 | 18 | ifndef TEST_ROOT 19 | TEST_ROOT := $(shell pwd)$(D).. 20 | endif 21 | 22 | COMPILATION_OUTPUT=$(TEST_ROOT)$(D)TKG$(D)output_compilation 23 | COMPILATION_LOG=$(COMPILATION_OUTPUT)$(D)compilation.log 24 | MOVE_TDUMP_PERL=perl scripts$(D)moveDmp.pl --compileLogPath=$(Q)$(COMPILATION_LOG)$(Q) --testRoot=$(Q)$(TEST_ROOT)$(Q) 25 | MOVE_TDUMP=if [ -z $(Q)$$(tail -1 $(COMPILATION_LOG) | grep 0)$(Q) ]; then $(MOVE_TDUMP_PERL); false; else $(RM) -r $(Q)$(COMPILATION_OUTPUT)$(Q); fi 26 | -------------------------------------------------------------------------------- /resources/buildPlatformMap.properties: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # https://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | aix_ppc-64_nocmprssptrs=ppc64_aix_xl 14 | aix_ppc-64_cmprssptrs=ppc64_aix_cmprssptrs 15 | aix_ppc-64=ppc64_aix 16 | aix_ppc=ppc32_aix 17 | alpine-linux_aarch64=aarch64_alpine-linux 18 | alpine-linux_x86-64=x86-64_alpine-linux 19 | linux_390-64_nocmprssptrs=s390x_linux_xl 20 | linux_390-64_cmprssptrs=s390x_linux_cmprssptrs 21 | linux_390-64_cmprssptrs_zt=s390x_linux_cmprssptrs_zt 22 | linux_390-64=s390x_linux 23 | linux_390-64_zt=s390x_linux_zt 24 | linux_390=s390_linux 25 | linux_aarch64_nocmprssptrs=aarch64_linux_xl 26 | linux_aarch64_cmprssptrs=aarch64_linux_cmprssptrs 27 | linux_aarch64=aarch64_linux 28 | linux_arm=arm_linux 29 | linux_ppc-64_nocmprssptrs=ppc64_linux_xl 30 | linux_ppc-64_cmprssptrs=ppc64_linux_cmprssptrs 31 | linux_ppc-64_cmprssptrs_le=ppc64le_linux_cmprssptrs 32 | linux_ppc-64_nocmprssptrs_le=ppc64le_linux_xl 33 | linux_ppc-64=ppc64_linux 34 | linux_ppc-64_le=ppc64le_linux 35 | linux_ppc=ppc32_linux 36 | linux_riscv64_nocmprssptrs=riscv64_linux_xl 37 | linux_riscv64_cmprssptrs=riscv64_linux_cmprssptrs 38 | linux_riscv64=riscv64_linux 39 | linux_loongarch64_nocmprssptrs=loongarch64_linux_xl 40 | linux_loongarch64_cmprssptrs=loongarch64_linux_cmprssptrs 41 | linux_loongarch64=loongarch64_linux 42 | linux_x86-64_nocmprssptrs=x86-64_linux_xl 43 | linux_x86-64_cmprssptrs=x86-64_linux_cmprssptrs 44 | linux_x86-64=x86-64_linux 45 | linux_x86=x86-32_linux 46 | osx_aarch64_nocmprssptrs=aarch64_mac_xl 47 | osx_aarch64_cmprssptrs=aarch64_mac_cmprssptrs 48 | osx_aarch64=aarch64_mac 49 | osx_x86-64_nocmprssptrs=x86-64_mac_xl 50 | osx_x86-64_cmprssptrs=x86-64_mac_cmprssptrs 51 | osx_x86-64=x86-64_mac 52 | sunos_sparcv9-64=sparcv9_solaris 53 | sunos_x86-64=x86-64_solaris 54 | win_x86-64_nocmprssptrs=x86-64_windows_xl 55 | win_x86-64_cmprssptrs=x86-64_windows_cmprssptrs 56 | win_x86-64=x86-64_windows 57 | win_aarch64=aarch64_windows 58 | win_x86=x86-32_windows 59 | zos_390-64_nocmprssptrs=s390x_zos_xl 60 | zos_390-64_cmprssptrs=s390x_zos_cmprssptrs 61 | zos_390-64_cmprssptrs_zt=s390x_zos_cmprssptrs_zt 62 | zos_390-64=s390x_zos 63 | zos_390-64_zt=s390x_zos_zt 64 | zos_390=s390_zos 65 | zos_390_zt=s390_zos_zt 66 | -------------------------------------------------------------------------------- /resources/playlist.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /runtest.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | # 16 | # Makefile to run various JVM tests 17 | # 18 | 19 | .DEFAULT_GOAL := test 20 | 21 | D = / 22 | 23 | SUBDIRS = .. 24 | 25 | ifndef TEST_ROOT 26 | TEST_ROOT := $(shell pwd)$(D).. 27 | endif 28 | 29 | include settings.mk 30 | -------------------------------------------------------------------------------- /scripts/build_test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | Compile Java Test Projects 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | build.list is ${build.list} 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /scripts/build_tools.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | Build tools 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Ant version is ${ant.version} 34 | ============COMPILER SETTINGS============ 35 | ===fork: yes 36 | ===debug: on 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /scripts/configure.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ################################################################################ 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ################################################################################ 16 | 17 | use Cwd; 18 | 19 | #Configure makefile dir 20 | my $configuredir=""; 21 | if (@ARGV) { 22 | $configuredir = $ARGV[0]; 23 | } else { 24 | $configuredir = cwd(); 25 | } 26 | my $machineConfiguremk = $configuredir . "/machineConfigure.mk"; 27 | unlink($machineConfiguremk); 28 | my $platform=`uname`; 29 | 30 | my $ZOSR14=3906; 31 | my %capability_Hash; 32 | 33 | if ($platform =~ /OS\/390/i) { 34 | 35 | my $hardware=`uname -m`; 36 | if ($hardware >= $ZOSR14) { 37 | $capability_Hash{guardedstorage} = 1; 38 | } 39 | } 40 | 41 | elsif ($platform =~ /Linux/i) { 42 | # virtual infor 43 | my $KVM_Image=`cat /proc/cpuinfo | grep -i QEMU`; 44 | my $VMWare_Image=`lspci 2>/dev/null | grep -i VMware` ; 45 | my $Virt_Sys=""; 46 | 47 | if ($KVM_Image ne "" ) { 48 | $Virt_Sys="KVM" 49 | } elsif ($VMWare_Image ne "") { 50 | $Virt_Sys="VMWare"; 51 | } 52 | $ENV{hypervisor} = $Virt_Sys; 53 | $capability_Hash{hypervisor} = $Virt_Sys; 54 | } 55 | else { 56 | exit; 57 | } 58 | 59 | if (%capability_Hash) { 60 | open( my $fhout, '>>', $machineConfiguremk ) or die "Cannot create file $machineConfiguremk $!"; 61 | while (my ($key, $value) = each %capability_Hash) { 62 | my $exportline = "export " . $key . "=" . $value. "\n"; 63 | print $fhout $exportline; 64 | delete $capability_Hash{$key}; 65 | } 66 | close $fhout; 67 | } 68 | -------------------------------------------------------------------------------- /scripts/getDependencies.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | Get Third Party Dependencies 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /scripts/getFileWithRetry.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FILE="" 16 | COMMAND="" 17 | 18 | parseCommandLineArgs() 19 | { 20 | while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do 21 | opt="$1"; 22 | shift; 23 | case "$opt" in 24 | "--file" | "-f" ) 25 | FILE="$1"; shift;; 26 | 27 | "--command" | "-c" ) 28 | COMMAND="$1"; shift;; 29 | 30 | *) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognized."; usage; exit 1; 31 | esac 32 | done 33 | } 34 | 35 | getFileWithRetry() 36 | { 37 | set +e 38 | count=0 39 | rt_code=-1 40 | # when the command is not found (code 127), do not retry 41 | while [ "$rt_code" != 0 ] && [ "$rt_code" != 127 ] && [ "$count" -le 5 ] 42 | do 43 | if [ "$count" -gt 0 ]; then 44 | sleep_time=300 45 | echo "error code: $rt_code. Sleep $sleep_time secs, then retry $count..." 46 | sleep $sleep_time 47 | 48 | echo "check for $FILE. If found, the file will be removed." 49 | if [ -e "$FILE" ]; then 50 | echo "remove $FILE before retry..." 51 | rm -r $FILE 52 | fi 53 | fi 54 | echo "$COMMAND" 55 | eval "$COMMAND" 56 | rt_code=$? 57 | count=$(( $count + 1 )) 58 | done 59 | set -e 60 | if [ $rt_code != 0 ]; then 61 | exit 1 62 | fi 63 | } 64 | 65 | parseCommandLineArgs "$@" 66 | getFileWithRetry 67 | 68 | -------------------------------------------------------------------------------- /scripts/getSHAs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | TEST_ROOT="" 16 | SHAs_FILE="" 17 | workDIR=$(pwd) 18 | 19 | usage () 20 | { 21 | echo 'This script use git command to get all shas in the provided TEST_ROOT and write the info into the SHAs file' 22 | echo 'Usage : ' 23 | echo ' --test_root_dir: optional' 24 | echo ' --shas_file: optional, the file to write the sha info to. Default is to ../SHAs.txt' 25 | } 26 | 27 | parseCommandLineArgs() 28 | { 29 | while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do 30 | opt="$1"; 31 | shift; 32 | case "$opt" in 33 | "--test_root_dir" | "-d" ) 34 | TEST_ROOT="$1"; shift;; 35 | 36 | "--shas_file" | "-f" ) 37 | SHAs_FILE="$1"; shift;; 38 | 39 | "--help" | "-h" ) 40 | usage; exit 0;; 41 | 42 | *) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognized."; usage; exit 1; 43 | esac 44 | done 45 | if [ -z "$TEST_ROOT" ] || [ -z "$SHAs_FILE" ] || [ ! -d "$TEST_ROOT" ]; then 46 | echo "Error, please see the usage and also check if $TEST_ROOT exists" 47 | usage 48 | exit 1 49 | fi 50 | } 51 | 52 | timestamp() 53 | { 54 | date +"%Y%m%d-%H%M%S" 55 | } 56 | 57 | getSHAs() 58 | { 59 | echo "Check shas in $TEST_ROOT and store the info in $SHAs_FILE" 60 | if [ ! -e "${SHAs_FILE}" ]; then 61 | echo "touch $SHAs_FILE" 62 | touch "$SHAs_FILE" 63 | fi 64 | 65 | # Get SHA for non-external tests by find .git dir 66 | cd "$TEST_ROOT" || exit 67 | find "$TEST_ROOT" -type d -name ".git" | while read -r gitDir; do 68 | repoDir=$(realpath "$(dirname "$gitDir")") 69 | cd "$repoDir" || continue 70 | # append the info into $SHAs_FILR 71 | { echo "================================================"; echo "timestamp: $(timestamp)"; echo "repo dir: $repoDir"; echo "git repo: "; git remote show origin -n | grep "Fetch URL:"; echo "sha:"; git rev-parse HEAD; } 2>&1 | tee -a "$SHAs_FILE" 72 | done 73 | 74 | cd "$TEST_ROOT" || exit 75 | # Get SHA for external tests by test.properties 76 | if [[ "$BUILD_LIST" == *"external"* ]]; then 77 | for subDir in "$TEST_ROOT"/external/*/; do 78 | # find "$subDir" -type f -name 'Dockerfile.*' 79 | if [[ $(find "$subDir" -type f -name 'Dockerfile.*') ]]; then 80 | propertiesFile="$subDir/test.properties" 81 | testDir=$(realpath "$subDir") 82 | if [[ -f "$propertiesFile" ]]; then 83 | # read github_url and tag_version 84 | github_url=$(grep '^github_url=' "$propertiesFile" | cut -d"=" -f2 | tr -d '"') 85 | tag_version=$(grep '^tag_version=' "$propertiesFile" | cut -d"=" -f2 | tr -d '"') 86 | 87 | if [[ -z "$github_url" || -z "$tag_version" ]]; then 88 | echo "No github_url or tag_version in $propertiesFile" 89 | continue 90 | fi 91 | 92 | # Retrieve the SHA using github_url and tag_version 93 | sha=$(git ls-remote "$github_url" "refs/tags/$tag_version" | awk '{print $1}') 94 | if [ -n "${sha}" ]; then 95 | # append the info into $SHAs_FILE 96 | { echo "================================================"; echo "timestamp: $(timestamp)"; echo "test dir: $testDir"; echo "git repo: $github_url"; echo "sha:$sha";} 2>&1 | tee -a "$SHAs_FILE" 97 | fi 98 | fi 99 | fi 100 | done 101 | fi 102 | } 103 | 104 | parseCommandLineArgs "$@" 105 | getSHAs 106 | cd "$workDIR" || exit 107 | -------------------------------------------------------------------------------- /scripts/getTestenvProperties.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | REPO_DIR="" 16 | OUTPUT_FILE="../testenv.properties" 17 | REPO_NAME="" 18 | REPO_SHA="" 19 | 20 | usage () 21 | { 22 | echo 'This script use git command to get sha in the provided REPO_DIR HEAD and write the info into the OUTPUT_FILE' 23 | echo 'Usage : ' 24 | echo ' --repo_dir: local git repo dir' 25 | echo ' --output_file: the file to write the sha info to. Default is to ../SHAs.txt' 26 | echo ' --repo_name: git repo name. It will be used as a parameter name in testenv.properties' 27 | echo ' --repo_sha: git repo sha. If this value is not provided, use git command to get the repo sha. Otherwise, use the provided sha.' 28 | echo ' USE_TESTENV_PROPERTIES: env variable. If set to false, regenerate testenv.properties to capture the repo and sha. Otherwise, do nothing. The existing testenv.properties file will be used.' 29 | echo ' JDK_IMPL: env variable. Only used for openjdk tests. If JDK_IMPL = openj9, append OPENJ9 in REPO_NAME for openjdk repo . i.e., JDK11_OPENJ9. Otherwise, REPO_NAME is unchanged.' 30 | } 31 | 32 | parseCommandLineArgs() 33 | { 34 | while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do 35 | opt="$1"; 36 | shift; 37 | case "$opt" in 38 | "--repo_dir" | "-d" ) 39 | REPO_DIR="$1"; shift;; 40 | 41 | "--output_file" | "-o" ) 42 | OUTPUT_FILE="$1"; shift;; 43 | 44 | "--repo_name" | "-n" ) 45 | REPO_NAME="$1"; shift;; 46 | 47 | "--repo_sha" | "-s" ) 48 | REPO_SHA="$1"; shift;; 49 | 50 | "--help" | "-h" ) 51 | usage; exit 0;; 52 | 53 | *) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognized."; usage; exit 1; 54 | esac 55 | done 56 | if [ -z "$REPO_DIR" ] || [ -z "$OUTPUT_FILE" ] || [ ! -d "$REPO_DIR" ]; then 57 | echo "Error, please see the usage and also check if $REPO_DIR is existing" 58 | usage 59 | exit 1 60 | fi 61 | } 62 | 63 | getTestenvProperties() 64 | { 65 | if [[ "$USE_TESTENV_PROPERTIES" != true ]]; then 66 | echo "Check sha in $REPO_DIR and store the info in $OUTPUT_FILE" 67 | if [ ! -e ${OUTPUT_FILE} ]; then 68 | echo "touch $OUTPUT_FILE" 69 | touch $OUTPUT_FILE 70 | fi 71 | 72 | cd $REPO_DIR 73 | 74 | # If the SHA was not passed in, get it from 75 | # the repository directly 76 | if [ -z "$REPO_SHA"]; then 77 | REPO_SHA="$(git rev-parse HEAD)" 78 | fi 79 | 80 | # For openjdk repo, append OPENJ9 in REPO_NAME if JDK_IMPL = openj9. i.e., JDK11_OPENJ9 81 | # Otherwise, REPO_NAME is unchanged. i.e., JDK11 82 | if [ $REPO_DIR == "openjdk-jdk" ] && [ $JDK_IMPL == "openj9" ]; then 83 | REPO_NAME="${REPO_NAME}_OPENJ9" 84 | fi 85 | 86 | branch="${REPO_NAME}_BRANCH" 87 | # for openj9, we need to use OPENJ9_SHA for now, not OPENJ9_BRANCH 88 | if [ $REPO_NAME == "OPENJ9" ]; then 89 | branch="${REPO_NAME}_SHA" 90 | fi 91 | 92 | # append the info into $OUTPUT_FILE 93 | { 94 | echo "${REPO_NAME}_REPO=$(git remote show origin -n | awk '/Fetch URL:/{print $3}')"; 95 | echo "${branch}=${REPO_SHA}"; 96 | } 2>&1 | tee -a $OUTPUT_FILE 97 | else 98 | echo "USE_TESTENV_PROPERTIES was set, not writing to testenv.properties" 99 | fi 100 | } 101 | 102 | parseCommandLineArgs "$@" 103 | getTestenvProperties 104 | -------------------------------------------------------------------------------- /scripts/getUniqueId.pl: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | use strict; 16 | use warnings; 17 | 18 | my $epoc = time(); 19 | my $rand = int rand(10000); 20 | print "$epoc$rand"; 21 | -------------------------------------------------------------------------------- /scripts/liveMonitor_countTests/README.md: -------------------------------------------------------------------------------- 1 | # LiveMonitor Scripts 2 | 3 | The liveMonitor scripts report on the number of openjdk tests or the live status in a particular directory, addressing the user story of a developer that is running tests locally and wishes to see the live status. 4 | 5 | ## User stories: 6 | - Developer wishes to know how many tests in total there are in a particular directory (more granular than test targets defined in playlists) 7 | 8 | - Developer wishes to have current test status during a live run of tests on their laptop (more granular that TAP results) 9 | 10 | [Related Issue](https://github.com/adoptium/TKG/issues/176) 11 | 12 | 13 | ## LiveMonitor Prerequisites 14 | 15 | - Python3 Installed 16 | 17 | - openjdk tests only, these tests are required to be piped before compiling the script 18 | 19 | `export BUILD_LIST=openjdk` 20 | 21 | 22 | 23 | 24 | 25 | ## count-java-tests 26 | 27 | The count-java-tests script counts how many test exists in a specified folder.It simply checks for the java files contains "@test" annotation. This script currently works on just openjdk tests. 28 | 29 | 30 | #### Sample usage: 31 | 32 | `aqa-tests/TKG# python3 -u scripts/liveMonitor_countTests/count-java-tests.py ../openjdk/openjdk-jdk/test/langtools/tools/javac/warnings/` 33 | 34 | #### Sample output: 35 | 36 | Counting tests in 'aqa-tests/openjdk/openjdk-jdk/test/langtools/tools/javac/warnings/' ... 37 | 38 | Found 41 java files 39 | 40 | . ................ 11 41 | 6594914 ........... 2 42 | 6747671 ........... 1 43 | 6885255 ........... 1 44 | 45 | 7090499 ........... 1 46 | AuxiliaryClass .... 3 47 | NestedDeprecation . 1 48 | suppress ......... 10 49 | 50 | 51 | 52 | Found 30 java files containing @test 53 | 54 | ## jtreg-monitor 55 | 56 | The jtreg-monitor provides the live status of the TAP results that have been running. 57 | 58 | 59 | Before running the scripts, the verbose option of jtreg needs to be changed. 60 | 61 | 62 | In [/openjdk/openjdk.mk](https://github.com/adoptium/aqa-tests/blob/master/openjdk/openjdk.mk) file: 63 | 64 | `JTREG_BASIC_OPTIONS += -v:fail,error,time,nopass` 65 | needs to be changed to: 66 | 67 | `JTREG_BASIC_OPTIONS += -v:all` 68 | 69 | #### Sample usage: 70 | 71 | `make _sanity.openjdk | python3 -u scripts/liveMonitor_countTests/jtreg-monitor.py` 72 | 73 | 74 | #### Sample output: 75 | 76 | //TKG# % make _sanity.openjdk | python3 -u scripts/liveMonitor_countTests/jtreg-monitor.py 77 | 78 | ============== MONITORING STDIN FOR JTREG RESULTS ============== 79 | 80 | openjdk version "17.0.2" 2022-01-18 81 | IBM Semeru Runtime Open Edition 17.0.2.0 (build 17.0.2+8) 82 | Eclipse OpenJ9 VM 17.0.2.0 (build openj9-0.30.0, JRE 17 Mac OS X amd64-64-Bit Compressed References 20220127_94 (JIT enabled, AOT enabled) 83 | OpenJ9 - 9dccbe076 84 | OMR - dac962a28 85 | JCL - 64cd399ca28 based on jdk-17.0.2+8) 86 | 87 | Attempting to destroy all caches in cacheDir //javasharedresources/ 88 | 89 | JVMSHRC806I Compressed references persistent shared cache "sharedcc_" has been destroyed. Use option -Xnocompressedrefs if you want to destroy a non-compressed references cache. 90 | JVMSHRC005I No shared class caches available 91 | 0:00:13.373978 / ...ng/annotation/AnnotationType/AnnotationTypeDeadlockTest.java / {} 92 | TEST (1) 0:00:00.000705 @ 2022-03-07 23:19:09): java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java Passed 93 | 0:00:13.374683 / ...ng/annotation/AnnotationType/AnnotationTypeDeadlockTest.java / {'Passed': 1} 94 | 0:00:13.760148 / java/lang/HashCode.java / {'Passed': 1} 95 | TEST (2) 0:00:00.000953 @ 2022-03-07 23:19:10): java/lang/HashCode.java Passed 96 | 0:00:13.761101 / java/lang/HashCode.java / {'Passed': 2} 97 | 0:00:14.111257 / java/lang/Compare.java / {'Passed': 2} 98 | TEST (3) 0:00:00.001275 @ 2022-03-07 23:19:10): java/lang/Compare.java Passed 99 | 0:00:14.112532 / java/lang/Compare.java / {'Passed': 3} 100 | 0:00:14.112637 / java/lang/IntegralPrimitiveToString.java / {'Passed': 3} 101 | 102 | ============== RESULTS ============== 103 | 104 | 105 | ============== Passed (3) ============== 106 | 107 | Passed (1/3796) - TEST (1) 0:00:00.000705 @ 2022-03-07 23:19:09): java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java Passed 108 | Passed (2/3796) - TEST (2) 0:00:00.000953 @ 2022-03-07 23:19:10): java/lang/HashCode.java Passed 109 | Passed (3/3796) - TEST (3) 0:00:00.001275 @ 2022-03-07 23:19:10): java/lang/Compare.java Passed 110 | 111 | ============== Error (3) ============== 112 | 113 | Error (1/10) - TEST (129) 0:00:00.000753 @ 2022-03-07 23:19:27): java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java 114 | -------> Error. Use -nativepath to specify the location of native code 115 | 116 | Error (2/10) - TEST (409) 0:00:00.000211 @ 2022-03-07 23:21:50): java/lang/ProcessBuilder/Basic.java#id0 117 | -------> Error. Use -nativepath to specify the location of native code 118 | 119 | Error (3/10) - TEST (536) 0:00:00.000235 @ 2022-03-07 23:22:15): java/lang/RuntimeTests/loadLibrary/exeLibraryCache/LibraryFromCache.java 120 | -------> Error. Use -nativepath to specify the location of native code 121 | 122 | ============== Failed (3) ============== 123 | 124 | Failed (1/10) - TEST (559) 0:00:00.000404 @ 2022-03-07 23:22:19): java/lang/StackWalker/DumpStackTest.java 125 | -------> Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: StackTraceElements mismatch at index 3. Expected [DumpStackTest.testLambda(DumpStackTest.java)], but get [DumpStackTest$$Lambda$3/0x000000008808c1a0.accept(Unknown Source)] 126 | 127 | Failed (2/10) - TEST (1350) 0:00:00.000345 @ 2022-03-07 23:27:03): java/lang/StackWalker/DumpStackTest.java 128 | -------> Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: StackTraceElements mismatch at index 3. Expected [DumpStackTest.testLambda(DumpStackTest.java)], but get [DumpStackTest$$Lambda$3/0x000000007811c1a0.accept(Unknown Source)] 129 | 130 | Failed (3/10) - TEST (2011) 0:00:00.000416 @ 2022-03-07 23:38:28): java/util/Currency/CurrencyTest.java 131 | -------> Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: Test data and JRE's currency data are inconsistent. test: (file: 3 data: 170), JRE: (file: 3 data: 169) 132 | 133 | ============== SUMMARY ============== 134 | 135 | Started: 2022-03-07 23:18:56 136 | Ended: 2022-03-08 00:04:06 137 | Time elapsed 0:45:09.979457 138 | Number of tests: 9 139 | Results: {'Passed': 3, 'Error': 3, 'Failed': 3} -------------------------------------------------------------------------------- /scripts/liveMonitor_countTests/count-java-tests.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | from sys import argv 16 | import os 17 | import glob 18 | 19 | if len(argv) != 2: 20 | print("Usage: count-java-tests.py [directory]") 21 | exit() 22 | 23 | searchDir = argv[1] 24 | if not os.path.isdir(searchDir): 25 | print("Error! '" + searchDir + "' is not a directory") 26 | exit() 27 | 28 | print("\nCounting tests in '" + searchDir + "' ...") 29 | 30 | 31 | def get_filepaths(directory, extension): 32 | file_paths = [] 33 | for root, directories, files in os.walk(directory): 34 | for filename in files: 35 | if filename.endswith(extension): 36 | filepath = os.path.join(root, filename) 37 | file_paths.append((root, filepath, filename)) 38 | return file_paths 39 | 40 | 41 | # Run the above function and store its results in a variable. 42 | full_file_paths = get_filepaths(searchDir, "java") 43 | 44 | print("\nFound " + str(len(full_file_paths)) + " java files\n") 45 | 46 | # check for file is test or not 47 | def control_file(file): 48 | fread = file.readlines() 49 | for line in fread: 50 | if '@test' in line: 51 | return True 52 | return False 53 | 54 | 55 | # count per directory and running count 56 | count = 0 57 | paths = {} 58 | for root, filepath, filename in full_file_paths: 59 | found = False 60 | try: 61 | found = control_file(open(filepath,mode='r')) 62 | except Exception as e: 63 | print("File couldn't opened.") 64 | print("File Path = ", filepath) 65 | print(e) 66 | print("\nTrying to ignore error and count the tests...") 67 | found = control_file(open(filepath, mode='r', errors="ignore")) 68 | if found: 69 | count = count + 1 70 | subdir = os.path.relpath(root, searchDir) 71 | if subdir in paths: 72 | paths[subdir] = paths[subdir] + 1 73 | else: 74 | paths[subdir] = 1 75 | 76 | formattedOutput = [] 77 | widestResult = 0 78 | for path in paths.keys(): 79 | formattedText = path + ":" + str(paths[path]) 80 | formattedOutput.append(formattedText) 81 | if len(formattedText) > widestResult: 82 | widestResult = len(formattedText) 83 | 84 | rows, columns = os.popen('stty size', 'r').read().split() 85 | 86 | widestResult = widestResult 87 | if widestResult < 20: 88 | widestResult = 20 89 | columnWidth = widestResult + 3 90 | numcols = int(columns) / columnWidth 91 | if numcols == 0: 92 | numcols = 1 93 | 94 | col = 0 95 | for text in sorted(formattedOutput): 96 | parts = text.split(':') 97 | padded = parts[0] + " " + ("." * (widestResult - len(text))) + " " + parts[1] + " " 98 | print(padded) 99 | col = col + 1 100 | if col >= numcols: 101 | col = 0 102 | print("") 103 | 104 | print("\n\nFound " + str(count) + " java files containing @test\n") 105 | -------------------------------------------------------------------------------- /scripts/liveMonitor_countTests/jtreg-monitor.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | from sys import stdin, argv 16 | import re 17 | import datetime 18 | import time 19 | 20 | testestimate = "" 21 | testestimatetitle = "" 22 | esttestint = 0 23 | if len(argv) == 2: 24 | testestimate = "/" + argv[1] 25 | esttestint = int(argv[1]) 26 | testestimatetitle = "(estimated " + argv[1] + " tests) " 27 | 28 | testResults = {} 29 | counts = {} 30 | start = datetime.datetime.now() 31 | lastTest = "" 32 | total = 0 33 | clearStatus = "" 34 | statusColors = { "Passed": u"\u001b[32m", "Error": u"\u001b[31m", "Failed": u"\u001b[31m" } 35 | resetColor = u"\u001b[0m" 36 | currentTest = "" 37 | print(resetColor + "\n============== MONITORING STDIN FOR JTREG RESULTS " + testestimatetitle + "==============\n") 38 | for line in stdin: 39 | # for debugging text file input 40 | #time.sleep(1) 41 | line = line.strip() 42 | now = datetime.datetime.now() 43 | if line.startswith("TEST: "): 44 | currentTest = line[len("TEST: "):] 45 | testStarted = now 46 | total = total + 1 47 | elif line.startswith("TEST RESULT: "): 48 | m = re.search(r'TEST RESULT:\s*([A-Za-z]+)', line) 49 | status = m.group(1) 50 | line = line[len("TEST RESULT: "):] 51 | #line = now.strftime("%Y-%m-%d %H:%M:%S") + " " + "[Test: " + str(total) + "] " + line 52 | if status in counts: 53 | counts[status] = counts[status] + 1 54 | else: 55 | counts[status] = 1 56 | testResults[status] = [] 57 | 58 | if status == "Passed": 59 | info = status 60 | postfix = "" 61 | prefix = "" 62 | else: 63 | info = "\n-------> " + line 64 | if postfix == "": 65 | prefix = "\n" 66 | else: 67 | prefix = "" 68 | postfix = "\n" 69 | 70 | summaryText = "TEST (" + str(total) + ") {}".format(now - testStarted)+ " @ " + testStarted.strftime("%Y-%m-%d %H:%M:%S") + "): " + currentTest + " " + info 71 | finalText = "TEST (" + str(total) + testestimate + ") {}".format(now - testStarted)+ " @ " + testStarted.strftime("%Y-%m-%d %H:%M:%S") + "): " + currentTest + " " + info 72 | print(clearStatus + prefix + statusColors[status] + finalText + resetColor + postfix) 73 | clearStatus = "" 74 | 75 | testResults[status].append(summaryText + postfix) 76 | 77 | else: 78 | continue 79 | 80 | maxlen = 60 81 | if len(currentTest) > maxlen: 82 | running = "..." + currentTest[slice(len(currentTest)-maxlen,len(currentTest))] 83 | else: 84 | running = currentTest 85 | nextStatus = '{}'.format(now - start) + " / " + running + " / " + str(counts) 86 | if esttestint > 0: 87 | percentage = str(int(float(100) * (float(total) / float(esttestint)))) 88 | nextStatus = percentage + "% / " + nextStatus 89 | print (clearStatus + nextStatus + "\r") 90 | clearStatus = (" " * len(nextStatus)) + "\r" 91 | 92 | print(clearStatus) 93 | print("\n\n============== RESULTS ==============\n") 94 | for status in testResults: 95 | results = testResults[status] 96 | num = len(results) 97 | count = 1 98 | print("\n" + statusColors[status] + "============== " + status + " (" + str(num) + ") ==============\n" + resetColor) 99 | for result in results: 100 | print(statusColors[status] + status + " (" + str(count) + "/" + str(num) + ") - " + resetColor + result) 101 | count = count + 1 102 | 103 | print("\n\n============== SUMMARY ==============\n") 104 | print('Started: ' + start.strftime("%Y-%m-%d %H:%M:%S")) 105 | print('Ended: ' + now.strftime("%Y-%m-%d %H:%M:%S")) 106 | print('Time elapsed {}'.format(now - start)) 107 | print("Number of tests: " + str(total - 1)) 108 | print("Results: " + str(counts) + "\n") 109 | -------------------------------------------------------------------------------- /scripts/remove_duplicate_tests.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import xml.etree.ElementTree as ET 16 | import argparse as ag 17 | 18 | def parse_apache_2_license(license_file): 19 | with open(license_file, 'r') as f: 20 | license_lines = f.readlines() 21 | 22 | license_lines = license_lines[190:201] 23 | f.close() 24 | license_lines = ''.join(['#' + line for line in license_lines]) 25 | return license_lines 26 | 27 | def remove_duplicate_test_tags(xml_file, license_file): 28 | tree = ET.parse(xml_file, 29 | parser=ET.XMLParser(target=ET.TreeBuilder(insert_comments=True))) 30 | root = tree.getroot() 31 | test_case_names = [] 32 | for test in root.findall('test'): 33 | test_case_name = test.find('testCaseName').text 34 | if test_case_name in test_case_names: 35 | root.remove(test) 36 | else: 37 | test_case_names.append(test_case_name) 38 | apache_license = '\n' 39 | 40 | tree.write(xml_file, encoding='UTF-8', xml_declaration=True) 41 | 42 | # add license comment 43 | with open(xml_file, 'r+') as f: 44 | content = f.readlines() 45 | content.insert(1, apache_license) 46 | content = ''.join(content) 47 | f.seek(0, 0) 48 | f.write(content) 49 | f.close() 50 | 51 | if __name__ == '__main__': 52 | parser = ag.ArgumentParser() 53 | parser.add_argument('-f','--xml-file', type = str, help='Path to playlist.xml', 54 | required=True) 55 | parser.add_argument('-l','--license-file', type = str, help='Path to Apache 2.0 LICENSE', 56 | required=True, default=None) 57 | args = parser.parse_args() 58 | remove_duplicate_test_tags(args.xml_file, args.license_file) 59 | -------------------------------------------------------------------------------- /scripts/testBot/autoModifier.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import re 16 | import os 17 | import argparse 18 | from pathlib import Path 19 | 20 | def main(): 21 | ap = argparse.ArgumentParser() 22 | ap.add_argument("-f", "--file", required=True, help="regex file name to modify") 23 | ap.add_argument("-s", "--find", required=True, help="regex string to search in file") 24 | ap.add_argument("-r", "--replace", required=True, help="regex string to replace found") 25 | ap.add_argument("-d", "--directory", required=True, help="directory to modify") 26 | run(vars(ap.parse_args())) 27 | 28 | 29 | def run(args): 30 | print(f"- searching file {args['file']} in {args['directory']}") 31 | files = find_files(args["file"], args['directory']) 32 | print(f"- updating file(s)") 33 | isModified = modifyFiles(files, args["find"], args["replace"]) 34 | return isModified 35 | 36 | 37 | def find_files(name, path): 38 | result = [] 39 | for root, dirs, files in os.walk(path): 40 | for filename in files: 41 | if re.match(name, filename): 42 | result.append(os.path.join(root, filename)) 43 | print(".", end="") 44 | print("\n") 45 | return result 46 | 47 | 48 | def modifyFiles(files, find, replace): 49 | isModified = False 50 | for file in files: 51 | pattern = re.compile(find) 52 | with open(file) as inFile: 53 | input = inFile.read() 54 | search = re.search(find, input) 55 | if search is not None: 56 | output = re.sub(find, replace, input) 57 | temp = file + ".temp" 58 | with open(temp, "w") as outFile: 59 | outFile.write(output) 60 | os.remove(file) 61 | os.rename(temp, file) 62 | print(f"updated {file}\n") 63 | isModified = True 64 | return isModified 65 | 66 | 67 | if __name__ == "__main__": 68 | main() 69 | -------------------------------------------------------------------------------- /scripts/testBot/disable.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import playlistModifier 16 | import argparse 17 | import re 18 | import sys 19 | import shlex 20 | 21 | def main(): 22 | ap = argparse.ArgumentParser() 23 | ap.add_argument("-m", "--message", required=True, help="exclude message") 24 | ap.add_argument("-d", "--directory", required=True, help="directory to modify") 25 | ap.add_argument("-c", "--comment", required=True, help="comment") 26 | ap.add_argument("-cp", "--copyright", required=False, default="false", help="update copyright date") 27 | args = vars(ap.parse_args()) 28 | 29 | newArgs = { 30 | "directory": args["directory"], 31 | "copyright": args["copyright"], 32 | "comment": args["comment"] 33 | } 34 | message = args["message"].strip() 35 | match = re.match(r"auto ([A-Za-z]+) test (.*)", message) 36 | 37 | if match: 38 | print(f"{args['message']}\n") 39 | statementlist = match.group(2).split(";") 40 | tests = [] 41 | for statement in statementlist: 42 | words = statement.strip().split(" ") 43 | test = {} 44 | for word in words: 45 | if "=" not in word: 46 | test["name"] = word 47 | elif m := re.match(r"impl=(.*)", word): 48 | test["impl"] = m.group(1) 49 | elif m := re.match(r"vendor=(.*)", word): 50 | test["vendor"] = m.group(1) 51 | elif m := re.match(r"ver=(.*)", word): 52 | test["ver"] = m.group(1) 53 | elif m := re.match(r"plat=(.*)", word): 54 | test["plat"] = m.group(1) 55 | elif m := re.match(r"testflag=(.*)", word): 56 | test["testflag"] = m.group(1) 57 | else: 58 | print(f"unrecognized argument: {word}") 59 | sys.exit(-1) 60 | tests.append(test) 61 | newArgs.update({ 62 | "mode": match.group(1), 63 | "tests": tests, 64 | }) 65 | playlistModifier.run(newArgs) 66 | 67 | else: 68 | print(f"unrecognized message: {args['message']}") 69 | sys.exit(-1) 70 | 71 | if __name__ == "__main__": 72 | main() -------------------------------------------------------------------------------- /scripts/testBot/playlistModifier.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import sys 16 | import copy 17 | import re 18 | import os 19 | import argparse 20 | from pathlib import Path 21 | import lxml.etree as etree 22 | import datetime 23 | 24 | def main(): 25 | ap = argparse.ArgumentParser() 26 | ap.add_argument("-d", "--directory", required=True, help="directory to modify") 27 | ap.add_argument("-m", "--mode", required=True, help="operation mode, e.g., exclude") 28 | ap.add_argument("-t", "--tests", required=False, help="exclude test list") 29 | ap.add_argument("-c", "--comment", required=False, help="comment") 30 | ap.add_argument("-cp", "--copyright", required=False, default="false", help="update copyright date") 31 | run(vars(ap.parse_args())) 32 | 33 | def run(args): 34 | print(f"- searching file playlist.xml in {args['directory']}") 35 | files = find_files("playlist.xml", args['directory']) 36 | if not files: 37 | print(f"Could not find file {args['file']}!") 38 | sys.exit(-1) 39 | print(f"- updating file(s)") 40 | if (args["mode"] == "format"): 41 | formatter(files, args) 42 | if (args["mode"] == "exclude"): 43 | for test in args["tests"]: 44 | updated = addDisabled(files, test, args) 45 | if not updated: 46 | print(f"Could not find test {test['name']}!") 47 | sys.exit(-1) 48 | 49 | def find_files(name, path): 50 | result = [] 51 | for root, dirs, files in os.walk(path): 52 | for filename in files: 53 | if re.match(rf"^{name}$", filename): 54 | result.append(os.path.join(root, filename)) 55 | print(".", end="") 56 | print("\n") 57 | return result 58 | 59 | def addDisabled(files, test, args): 60 | updated = False 61 | testCaseName = test["name"] 62 | match = re.match(r"^(\S+)_(\d+)$", testCaseName) 63 | nthVar = None 64 | if match: 65 | testCaseName = match.group(1) 66 | nthVar = int(match.group(2)) 67 | for file in files: 68 | root = etree.parse(file) 69 | testEle = root.xpath(f"./test/testCaseName[text()='{testCaseName}']/..") 70 | if testEle: 71 | disable = etree.Element("disable") 72 | commentEle = etree.Element("comment") 73 | commentEle.text = args["comment"] 74 | disable.append(commentEle) 75 | if nthVar is not None: 76 | var = testEle[0].find("variations") 77 | if var is not None and nthVar < len(var): 78 | disable.append(copy.deepcopy(var[nthVar])) 79 | elif nthVar == 0: 80 | varEle = etree.Element("variation") 81 | varEle.text = "NoOptions" 82 | disable.append(varEle) 83 | else: 84 | print(f"Could not find test case {testCaseName}_{nthVar} (i.e., the {nthVar + 1}th variation for test {testCaseName})!") 85 | sys.exit(-1) 86 | if "ver" in test: 87 | verEle = etree.Element("version") 88 | verEle.text = test["ver"] 89 | disable.append(verEle) 90 | if "impl" in test: 91 | implEle = etree.Element("impl") 92 | implEle.text = test["impl"] 93 | disable.append(implEle) 94 | if "vendor" in test: 95 | vendorEle = etree.Element("vendor") 96 | vendorEle.text = test["vendor"] 97 | disable.append(vendorEle) 98 | if "plat" in test: 99 | platEle = etree.Element("platform") 100 | platEle.text = test["plat"] 101 | disable.append(platEle) 102 | if "testflag" in test: 103 | testflagEle = etree.Element("testflag") 104 | testflagEle.text = test["testflag"] 105 | disable.append(testflagEle) 106 | disables = testEle[0].find("disables") 107 | if disables is None: 108 | disables = etree.Element("disables") 109 | disables.append(disable) 110 | testCaseName = testEle[0].find("testCaseName") 111 | testCaseName.addnext(disables) 112 | updateCopyright(root, args) 113 | updateFile(file, root) 114 | updated = True 115 | return updated 116 | 117 | def formatter(files, args): 118 | for file in files: 119 | root = etree.parse(file) 120 | updateCopyright(root, args) 121 | updateFile(file, root) 122 | 123 | def updateCopyright(root, args): 124 | if (args["copyright"] == "true"): 125 | cr = root.xpath(f"/comment()") 126 | if cr: 127 | crtext = cr[0].text 128 | find = fr"(.*)(Copyright \(c\) \d{{4}}, )(\d{{4}})(.*)" 129 | search = re.search(find, crtext) 130 | year = datetime.datetime.now().year 131 | if (search is not None) and (search.group(3) != str(year)): 132 | replace = fr"\g<1>\g<2>{year}\g<4>" 133 | newcrtext = re.sub(find, replace, crtext, flags=re.DOTALL) 134 | cr[0].text = newcrtext 135 | 136 | def updateFile(file, root): 137 | etree.indent(root, "\t") 138 | temp = file + ".temp" 139 | with open(temp, 'wb') as outfile: 140 | root.write(outfile, pretty_print=True, xml_declaration=True, encoding="utf-8") 141 | os.remove(file) 142 | os.rename(temp, file) 143 | print(f"updated {file}\n") 144 | 145 | if __name__ == "__main__": 146 | main() 147 | -------------------------------------------------------------------------------- /scripts/testBot/runAqaArgParse.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import sys 4 | 5 | from pathlib import Path 6 | 7 | def map_platforms(platforms): 8 | """ Takes in a list of platforms and translates Grinder platorms to corresponding GitHub-hosted runners. 9 | This function both modifies and returns the 'platforms' argument. 10 | """ 11 | 12 | platform_map = { 13 | 'x86-64_windows': 'windows-latest', 14 | 'x86-64_mac': 'macos-latest', 15 | 'x86-64_linux': 'ubuntu-latest' 16 | } 17 | 18 | for i, platform in enumerate(platforms): 19 | if platform in platform_map: 20 | platforms[i] = platform_map[platform] 21 | 22 | return platforms 23 | 24 | def underscore_targets(targets): 25 | """ Takes in a list of targets and prefixes them with an underscore if they do not have one. 26 | """ 27 | result = [] 28 | for target in targets: 29 | t = target 30 | if target[0] != '_': 31 | t = '_' + t 32 | result.append(t) 33 | return result 34 | 35 | def main(): 36 | 37 | # The keyword for this command. 38 | keyword = 'run aqa' 39 | keywords = keyword.split() 40 | 41 | # We assume that the first argument is/are the keyword(s). 42 | # e.g. sys.argv == ['action_argparse.py', 'run', 'aqa', ...] 43 | raw_args = sys.argv[1 + len(keywords):] 44 | 45 | # Strip leading and trailing whitespace. Remove empty arguments that may result after stripping. 46 | raw_args = list(filter(lambda empty: empty, map(lambda s: s.strip(), raw_args))) 47 | 48 | parser = argparse.ArgumentParser(prog=keyword, add_help=False) 49 | # Improvement: Automatically resolve the valid choices for each argument populate them below, rather than hard-coding choices. 50 | parser.add_argument('--help', '-h', action='store_true') 51 | parser.add_argument('--sdk_resource', default=['nightly'], choices=['nightly', 'releases', 'customized', 'build-jdk'], nargs='+') 52 | parser.add_argument('--build_repo', default=['adoptium/build-jdk:master'], nargs='+') 53 | parser.add_argument('--customized_sdk_url', default=['None'], nargs='+') 54 | parser.add_argument('--archive_extension', default=['.tar'], choices=['.zip', '.tar', '.7z'], nargs='+') 55 | parser.add_argument('--build_list', default=['openjdk'], choices=['openjdk', 'functional', 'system', 'perf', 'external'], nargs='+') 56 | parser.add_argument('--target', default=['_jdk_math'], nargs='+') 57 | parser.add_argument('--platform', default=['x86-64_linux'], nargs='+') 58 | parser.add_argument('--jdk_version', default=['8'], nargs='+') 59 | parser.add_argument('--jdk_impl', default=['openj9'], choices=['hotspot', 'openj9'], nargs='+') 60 | parser.add_argument('--openjdk_testrepo', default=['adoptium/aqa-tests:master'], nargs='+') 61 | parser.add_argument('--openj9_repo', default=['eclipse-openj9/openj9:master'], nargs='+') 62 | parser.add_argument('--tkg_repo', default=['adoptium/TKG:master'], nargs='+') 63 | 64 | # Custom repo options which may be enabled/disabled in the `runAqaConfig.json` file. 65 | runaqa_config_json = Path('main/.github/workflows/runAqaConfig.json') 66 | if runaqa_config_json.is_file(): 67 | with open(runaqa_config_json) as f: 68 | config = json.load(f) 69 | if 'workflow_repo' in config: 70 | parser.add_argument('--workflow_repo', default=[config['workflow_repo']], nargs='+') 71 | 72 | args = vars(parser.parse_args(raw_args)) 73 | # All args are lists of strings 74 | 75 | # Help was requested. The simplest way to handle this is as if it were an error 76 | # because stdout is reserved for workflow commands and logs. 77 | if args['help']: 78 | # For some unknown reason, the first tilde in this help message should not be escaped, 79 | # otherwise a syntax error occurs when passed to the GitHub Script. 80 | help_msg = '''Run AQA GitHub Action Documentation 81 | `\\`\\` 82 | https://github.com/adoptium/aqa-tests/blob/master/doc/RunAqa.md 83 | \\`\\`\\` 84 | Click the above link to view the documentation for the Run AQA GitHub Workflow''' 85 | sys.stderr.write(help_msg) 86 | print('::error ::Help command invoked') 87 | exit(2) 88 | # Remove help flag from the args because it is not a parameter for the job matrix. 89 | del args['help'] 90 | 91 | # Map grinder platform names to github runner names 92 | args['jdk_platform'] = args['platform'].copy() 93 | args['platform'] = map_platforms(args['platform']) 94 | 95 | # Underscore the targets if necessary 96 | args['target'] = underscore_targets(args['target']) 97 | 98 | # Split repo and branch from the `build_repo` arg since it is not handled by the AdoptOpenJDK/build-jdk action. 99 | build_repo_branch = [] 100 | for br in args['build_repo']: 101 | spl = br.split(':') 102 | if len(spl) != 2: 103 | err_msg = 'Invalid repo+branch suppplied to argument --build_repo. Expecting format :' 104 | print('::error ::{}'.format(err_msg)) 105 | sys.stderr.write(err_msg) 106 | exit(2) 107 | repo, branch = spl 108 | entry = {'repo': repo, 'branch': branch} 109 | build_repo_branch.append(entry) 110 | args['build_repo_branch'] = build_repo_branch 111 | 112 | # If 'customized' sdk_resource, then customized_sdk_url and archive_extension must be present. 113 | if 'customized' in args['sdk_resource'] and args['customized_sdk_url'] == ['None']: 114 | err_msg = '--customized_sdk_url must be provided if sdk_resource is set to customized.' 115 | print('::error ::{}'.format(err_msg)) 116 | sys.stderr.write(err_msg) 117 | exit(2) 118 | 119 | # Add default customized_sdk_url for openj9 workflow when sdk_resource is nightly 120 | if 'workflow_repo' in args and 'eclipse-openj9/openj9' in args['workflow_repo'] and 'nightly' in args['sdk_resource'] and args['customized_sdk_url'] == ['None'] and 'openj9' in args['jdk_impl']: 121 | args['customized_sdk_url'] = [f'https://openj9-artifactory.osuosl.org/artifactory/ci-openj9/Build_JDK{args["jdk_version"][0]}_{args["jdk_platform"][0]}_Nightly/'] 122 | 123 | # Output the arguments 124 | print('::set-output name=build_parameters::{}'.format(json.dumps(args))) 125 | for key, value in args.items(): 126 | print('::set-output name={}::{}'.format(key, value)) 127 | 128 | if __name__ == "__main__": 129 | main() 130 | -------------------------------------------------------------------------------- /scripts/testTKG/testRunner.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import argparse 16 | import sys 17 | import os 18 | 19 | from utils import * 20 | from os import listdir 21 | from os.path import isfile, join 22 | 23 | def main(): 24 | ap = argparse.ArgumentParser() 25 | ap.add_argument('-t','--test', nargs='+', required=False, default=[], help="space separated test list") 26 | ap.add_argument('-v','--verbose', nargs='?', required=False, const=True, default=False, help="print test output") 27 | args = vars(ap.parse_args()) 28 | test_list = args['test'] 29 | 30 | if not test_list: 31 | test_files = [f for f in listdir(os.getcwd()) if isfile(join(os.getcwd(), f)) and f.startswith("test_")] 32 | for file in test_files: 33 | test_file_strs = file.split(".") 34 | test_list.append(test_file_strs[0]) 35 | 36 | if args['verbose']: 37 | setVerboseLevel("verbose") 38 | 39 | rt = True 40 | 41 | for test in test_list: 42 | __import__(test) 43 | test_module = sys.modules[test] 44 | rt &= test_module.run_test() 45 | 46 | if rt: 47 | print("ALL TESTS PASSED") 48 | else: 49 | print("FAILED") 50 | exit(1) 51 | 52 | if __name__ == "__main__": 53 | main() 54 | -------------------------------------------------------------------------------- /scripts/testTKG/test_base.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | def run_test(): 19 | rt = True 20 | printTestheader("base") 21 | 22 | buildList = "TKG/examples/base" 23 | command = "make _all" 24 | print(f"\t{command}") 25 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 26 | rt &= checkResult(result, {'testSuccess_0'}, {'testFail_0'}, set(), set()) 27 | 28 | command = "make _testSuccess" 29 | print(f"\t{command}") 30 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 31 | rt &= checkResult(result, {'testSuccess_0'}, set(), set(), set()) 32 | return rt 33 | 34 | if __name__ == "__main__": 35 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/test_feature.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | def run_test(): 19 | rt = True 20 | printTestheader("feature") 21 | 22 | buildList = "TKG/examples/feature" 23 | command = "make _all" 24 | print(f"\t{command}") 25 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 26 | rt &= checkResult(result, {'testFeatureFips_0', 'testFeatureFipsNoApplicable_0'}, set(), set(), set()) 27 | 28 | buildList = "TKG/examples/feature" 29 | command = "make _all" 30 | testFlag = "export TEST_FLAG=FIPS140_2" 31 | print(f"\t{testFlag}; {command}") 32 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {testFlag}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 33 | rt &= checkResult(result, {'testFeatureFips_0'}, set(), set(), set()) 34 | 35 | command = "make _all" 36 | testFlag = "export TEST_FLAG=FIPS140_3_20220501" 37 | print(f"\t{testFlag}; {command}") 38 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {testFlag}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 39 | rt &= checkResult(result, {'testFeatureFips_0', 'testFeatureFipsNoApplicable_0'}, set(), set(), set()) 40 | 41 | command = "make _all" 42 | testFlag = "export TEST_FLAG=FIPS140_3_20230511" 43 | print(f"\t{testFlag}; {command}") 44 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {testFlag}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 45 | rt &= checkResult(result, {'testFeatureFips_0', 'testFeatureFipsNoApplicable_0', 'testFeatureFipsRegexRequired_0'}, set(), set(), set()) 46 | 47 | command = "make _all" 48 | testFlag = "export TEST_FLAG=FIPS140_3_20220101" 49 | print(f"\t{testFlag}; {command}") 50 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {testFlag}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 51 | rt &= checkResult(result, {'testFeatureFips_0', 'testFeatureFipsNoApplicable_0', 'testFeatureFipsRequired_0'}, set(), set(), set()) 52 | 53 | return rt 54 | 55 | if __name__ == "__main__": 56 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/test_hierarchy.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | def run_test(): 19 | rt = True 20 | printTestheader("hierarchy") 21 | 22 | buildList = "TKG/examples/hierarchy" 23 | command = "make _all" 24 | print(f"\t{command}") 25 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 26 | rt &= checkResult(result, {'test_a1_b1_0', 'test_a2_0', 'test_a2_b2_0', 'test_a2_b2_c2_0', 'test_a2_d2_0', 'test_a3_b3_0', 'test_a3_b3_c3_d3_0', 'test_a3_f3_0'}, set(), set(), set()) 27 | 28 | command = "make _test_a3_b3_c3_d3_0" 29 | print(f"\t{command}") 30 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 31 | rt &= checkResult(result, {'test_a3_b3_c3_d3_0'}, set(), set(), set()) 32 | 33 | buildList = "TKG/examples/hierarchy/a2/b2,TKG/examples/hierarchy/a3/f3" 34 | command = "make _all" 35 | print(f"\t{command}") 36 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 37 | rt &= checkResult(result, {'test_a2_b2_0', 'test_a2_b2_c2_0', 'test_a3_f3_0'}, set(), set(), set()) 38 | 39 | return rt 40 | 41 | if __name__ == "__main__": 42 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/test_jdkVersion.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | def run_test(): 19 | rt = True 20 | printTestheader("jdkVersion") 21 | 22 | buildList = "TKG/examples/jdkVersion" 23 | command = "make _all" 24 | print(f"\t{command}") 25 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 26 | 27 | stdout = result.stdout.decode() 28 | verStr = re.search(r"set JDK_VERSION to (.*)", stdout) 29 | 30 | if verStr is not None: 31 | try: 32 | ver = int(verStr.group(1)) 33 | except ValueError: 34 | print("\tTest Skipped! JDK_VERSION is not integer.") 35 | return True 36 | else: 37 | printError("Could not parse JDK_VERSION from output.") 38 | return False 39 | 40 | passed = set() 41 | disabled = set() 42 | 43 | if 8 <= ver < 11: 44 | passed.add('test_ver_8to11_0') 45 | passed.add('test_ver_8to11and17plus_0') 46 | passed.add('test_disable_ver_11_0') 47 | passed.add('test_disable_ver_11to17_0') 48 | disabled.add('test_disable_ver_8and17plus_0') 49 | elif ver == 11: 50 | passed.add('test_ver_11_0') 51 | passed.add('test_ver_8to11_0') 52 | passed.add('test_ver_8to11and17plus_0') 53 | disabled.add('test_disable_ver_11_0') 54 | disabled.add('test_disable_ver_11to17_0') 55 | passed.add('test_disable_ver_8and17plus_0') 56 | elif ver >= 17: 57 | passed.add('test_ver_17plus_0') 58 | passed.add('test_ver_8to11and17plus_0') 59 | passed.add('test_disable_ver_11_0') 60 | disabled.add('test_disable_ver_11to17_0') 61 | disabled.add('test_disable_ver_8and17plus_0') 62 | 63 | rt &= checkResult(result, passed, set(), disabled, set()) 64 | return rt 65 | 66 | if __name__ == "__main__": 67 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/test_level.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | def run_test(): 19 | rt = True 20 | printTestheader("level") 21 | 22 | buildList = "TKG/examples/sliceAndDice/level" 23 | 24 | command = "make _sanity" 25 | print(f"\t{command}") 26 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 27 | rt &= checkResult(result, {'testSanity_0'}, set(), set(), set()) 28 | 29 | command = "make _extended" 30 | print(f"\t{command}") 31 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 32 | rt &= checkResult(result, {'testDefault_0', 'testExtended_0'}, set(), set(), set()) 33 | 34 | command = "make _dev" 35 | print(f"\t{command}") 36 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 37 | rt &= checkResult(result, {'testDev_0'}, set(), set(), set()) 38 | 39 | command = "make _special" 40 | print(f"\t{command}") 41 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 42 | rt &= checkResult(result, {'testSpecial_0'}, set(), set(), set()) 43 | 44 | command = "make _all" 45 | print(f"\t{command}") 46 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 47 | rt &= checkResult(result, {'testSanity_0', 'testDefault_0', 'testExtended_0', 'testDev_0', 'testSpecial_0'}, set(), set(), set()) 48 | return rt 49 | 50 | if __name__ == "__main__": 51 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/test_platformRequirements.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | def run_test(): 19 | rt = True 20 | printTestheader("platformRequirements") 21 | 22 | buildList = "TKG/examples/platformRequirements" 23 | command = "make _all" 24 | print(f"\t{command}") 25 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 26 | 27 | stdout = result.stdout.decode() 28 | specStr = re.search(r"set SPEC to (.*)", stdout) 29 | 30 | if specStr is not None: 31 | spec = specStr.group(1) 32 | else: 33 | printError("Could not parse spec from output.") 34 | return False 35 | 36 | passed = set() 37 | skipped = set() 38 | 39 | if 'linux' in spec: 40 | skipped.add('test_not_linux_arch_x86_0') 41 | else: 42 | if 'x86' in spec: 43 | passed.add('test_not_linux_arch_x86_0') 44 | else: 45 | skipped.add('test_not_linux_arch_x86_0') 46 | 47 | if 'x86' in spec: 48 | passed.add('test_arch_x86_0') 49 | skipped.add('test_arch_nonx86_0') 50 | else: 51 | passed.add('test_arch_nonx86_0') 52 | skipped.add('test_arch_x86_0') 53 | 54 | if '64' in spec: 55 | passed.add('test_bits_64_0') 56 | else: 57 | skipped.add('test_bits_64_0') 58 | 59 | if 'osx' in spec: 60 | passed.add('test_os_osx_0') 61 | else: 62 | skipped.add('test_os_osx_0') 63 | 64 | if 'osx_x86-64' in spec: 65 | passed.add('test_osx_x86-64_0') 66 | else: 67 | skipped.add('test_osx_x86-64_0') 68 | 69 | if 'x86' in spec or '390' in spec: 70 | passed.add('test_arch_x86_390_0') 71 | else: 72 | skipped.add('test_arch_x86_390_0') 73 | 74 | if 'osx_x86-64' in spec or ('win_x86' in spec and 'win_x86-64' not in spec) or 'aix_ppc-64' in spec: 75 | passed.add('test_osx_x86-64_win_x86_aix_ppc-64_0') 76 | else: 77 | skipped.add('test_osx_x86-64_win_x86_aix_ppc-64_0') 78 | 79 | os_label = re.search(r"set OS_LABEL to (.*)", stdout) 80 | print("os_label in : {}".format(os_label)) 81 | if os_label is not None: 82 | os_label = os_label.group(1) 83 | label_str = os_label.split(".") 84 | # os_label example: ubuntu.22 85 | try: 86 | ver = int(label_str[1],10) 87 | if label_str[0] == "ubuntu": 88 | if ver >= 22: 89 | passed.add('test_os_linux_ubuntu22_0') 90 | if ver >= 20: 91 | passed.add('test_os_linux_ubuntu20plus_0') 92 | passed.add('test_os_linux_ubuntu20plus_rhel8plus_0') 93 | if ver < 20: 94 | passed.add('test_not_os_linux_ubuntu20plus_0') 95 | 96 | if label_str[0] == "rhel": 97 | if ver >= 8: 98 | passed.add('test_os_linux_ubuntu20plus_rhel8plus_0') 99 | except ValueError as ve: 100 | print ("warning: os version value failed to convert to an integer") 101 | passed.add('test_not_os_linux_ubuntu20plus_0') 102 | else: 103 | passed.add('test_not_os_linux_ubuntu20plus_0') 104 | 105 | if 'test_os_linux_ubuntu20plus_0' not in passed: 106 | skipped.add('test_os_linux_ubuntu20plus_0') 107 | 108 | if 'test_os_linux_ubuntu22_0' not in passed: 109 | skipped.add('test_os_linux_ubuntu22_0') 110 | 111 | if 'test_os_linux_ubuntu20plus_rhel8plus_0' not in passed: 112 | skipped.add('test_os_linux_ubuntu20plus_rhel8plus_0') 113 | 114 | if 'test_not_os_linux_ubuntu20plus_0' not in passed: 115 | skipped.add('test_not_os_linux_ubuntu20plus_0') 116 | 117 | micro_arch = re.search(r"set MICROARCH to (.*)", stdout) 118 | # micro_arch = "set MICROARCH to z14" 119 | print("micro_arch in platform req: {}".format(micro_arch)) 120 | pattern = r"set MICROARCH to (.*)" 121 | # micro_arch = re.search(pattern, micro_arch) 122 | if micro_arch is not None: 123 | print(micro_arch) 124 | micro_arch = micro_arch.group(1) 125 | label_str = micro_arch 126 | print("Label_str:",label_str) 127 | # micro_arch example: skylake 128 | try: 129 | ver = int(''.join(filter(str.isdigit, micro_arch.split()[-1]))) 130 | print("ver:",ver) 131 | if label_str == "skylake": 132 | passed.add('test_arch_x86_skylake_0') 133 | if ver == 13: 134 | passed.add('test_arch_390_z13_0') 135 | elif ver > 13: 136 | passed.add('test_arch_390_z13plus_0') 137 | if ver == 14: 138 | passed.add('test_arch_390_z14_0') 139 | elif ver > 14: 140 | passed.add('test_arch_390_z14plus_0') 141 | if ver == 15: 142 | passed.add('test_arch_390_z15_0') 143 | elif ver > 15: 144 | passed.add('test_arch_390_z15plus_0') 145 | else: 146 | skipped.add('test_not_arch_390_0') 147 | except ValueError as ve: 148 | print("warning: microarch version value failed to convert to an integer") 149 | skipped.add('test_not_arch_390_0') 150 | else: 151 | passed.add('test_not_arch_390_0') 152 | passed.add('test_not_arch_390_z15plus_0') 153 | 154 | if 'test_arch_390_z15_0' not in passed: 155 | skipped.add('test_arch_390_z15_0') 156 | 157 | if 'test_arch_390_z14_0' not in passed: 158 | skipped.add('test_arch_390_z14_0') 159 | 160 | if 'test_arch_390_z13_0' not in passed: 161 | skipped.add('test_arch_390_z13_0') 162 | 163 | if 'test_arch_390_z15plus_0' not in passed: 164 | skipped.add('test_arch_390_z15plus_0') 165 | 166 | if 'test_arch_390_z14plus_0' not in passed: 167 | skipped.add('test_arch_390_z14plus_0') 168 | 169 | if 'test_arch_390_z13plus_0' not in passed: 170 | skipped.add('test_arch_390_z13plus_0') 171 | 172 | if 'test_arch_x86_skylake_0' not in passed: 173 | skipped.add('test_arch_x86_skylake_0') 174 | 175 | 176 | rt &= checkResult(result, passed, set(), set(), skipped) 177 | return rt 178 | 179 | if __name__ == "__main__": 180 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/test_rerun.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import subprocess 16 | from utils import * 17 | 18 | # test rerun tag 19 | def run_test(): 20 | rt = True 21 | printTestheader("rerun") 22 | 23 | rt &= test_rerun_helper("all", ["testIgnoreOnRerun_0", "testIgnoreOnRerunSubDir_0", "testIgnoreOnRerunSubDir_1"], ["testRerun_0", "testDefault_0", "testIgnoreOnRerun_0", "testRerunSubDir_0", "testDefaultSubDir_0", "testIgnoreOnRerunSubDir_0", "testIgnoreOnRerunSubDir_1"]) 24 | rt &= test_rerun_helper("system", ["testIgnoreOnRerunSubDir_0", "testIgnoreOnRerunSubDir_1"], ["testIgnoreOnRerunSubDir_0", "testIgnoreOnRerunSubDir_1"]) 25 | rt &= test_rerun_helper("perf", [""], set()) 26 | 27 | if not rt: 28 | return False 29 | else: 30 | print("\tTest successful!") 31 | return True 32 | 33 | # run target and validate IGNORE_ON_RERUN in the rerun.mk are as expected 34 | def test_rerun_helper(target, expected_ignore_on_rerun_list, expected_success): 35 | buildList = "TKG/examples/rerun" 36 | command = f"make _{target}" 37 | print(f"\t{command}") 38 | result = subprocess.run(f"{EXPORT_BUILDLIST}={buildList}; {CD_TKG}; {MAKE_CLEAN}; {MAKE_COMPILE}; {command}", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, check=False) 39 | 40 | rt = checkResult(result, expected_success, set(), set(), set()) 41 | 42 | if not rt: 43 | return False 44 | 45 | regex = re.compile(r"IGNORE_ON_RERUN=(.*)") 46 | utils_file = "../../rerun.mk" 47 | ignore_on_rerun_tests = "" 48 | with open(utils_file) as f: 49 | for line in f: 50 | result = regex.search(line) 51 | if result is not None: 52 | ignore_on_rerun_tests = result.group(1) 53 | 54 | ignore_on_rerun_list = ignore_on_rerun_tests.split(",") 55 | 56 | if set(expected_ignore_on_rerun_list) == set(ignore_on_rerun_list): 57 | print("\tIgnore on rerun list check successful!") 58 | return True 59 | else: 60 | printError("\tIgnore on rerun list check failed!") 61 | printError(f"expected ignore on rerun list: {expected_ignore_on_rerun_list}; actual list:{ignore_on_rerun_list}") 62 | return False 63 | 64 | if __name__ == "__main__": 65 | run_test() -------------------------------------------------------------------------------- /scripts/testTKG/utils.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ################################################################################ 14 | 15 | import re 16 | import textwrap 17 | 18 | CD_TKG = "cd ../../" 19 | MAKE_CLEAN = "make clean" 20 | MAKE_COMPILE = "make compile" 21 | DYNAMIC_COMPILE = "export DYNAMIC_COMPILE=true" 22 | EXPORT_BUILDLIST = "export BUILD_LIST" 23 | log_level = "default" 24 | 25 | def setVerboseLevel(level): 26 | global log_level 27 | log_level = level 28 | 29 | def printTestheader(msg): 30 | print(f"---------------------------------\nRun test: {msg}") 31 | 32 | def printError(msg): 33 | print(f"\tError: {msg}") 34 | 35 | def checkTestNum(group, expected, result): 36 | if expected != result: 37 | printError(f"expected {group} number: {expected}; actual number: {result} ") 38 | return False 39 | return True 40 | 41 | def checkTestDetail(group, detailBlock, expected): 42 | rt = True 43 | result = re.search(f"{group} test targets:\n(.*?)\n\n", detailBlock, flags=re.DOTALL) 44 | if result is not None: 45 | tests = result.group(1).split() 46 | if len(tests) != len(expected): 47 | rt = False 48 | for test in tests: 49 | if test not in expected: 50 | rt = False 51 | break 52 | if not rt: 53 | printError(f"expected {group} list: {expected}; actual list:{tests}") 54 | return rt 55 | 56 | def checkResult(result, passed, failed, disabled, skipped): 57 | global verbose 58 | rt = True 59 | stdout = result.stdout.decode() 60 | stderr = result.stderr.decode() 61 | if len(failed) == 0 ^ result.returncode != 0: 62 | printError(f"test exit code: {result.returncode} is not expected") 63 | 64 | summary = re.search(r"TEST TARGETS SUMMARY\n\+{74}\n(.*)TOTAL: (\d+) EXECUTED: (\d+) PASSED: (\d+) FAILED: (\d+) DISABLED: (\d+) SKIPPED: (\d+)\n(.*)\+{74}", stdout, flags=re.DOTALL) 65 | 66 | if log_level == "verbose": 67 | stdout = textwrap.indent(stdout, '\t') 68 | stderr = textwrap.indent(stderr, '\t') 69 | print(f"\tstdout:\n{stdout}\n\n") 70 | print(f"\tstderr:\n{stderr}\n\n") 71 | 72 | if summary is None: 73 | printError("test not completed") 74 | return False 75 | 76 | # print(summary.group()) 77 | testDetail = summary.group(1) 78 | totalNum = int(summary.group(2)) 79 | exectuedNum = int(summary.group(3)) 80 | passedNum = int(summary.group(4)) 81 | failedNum = int(summary.group(5)) 82 | disabledNum = int(summary.group(6)) 83 | skippedNum = int(summary.group(7)) 84 | rt &= checkTestNum('PASSED', len(passed), passedNum) 85 | rt &= checkTestDetail("PASSED", testDetail, passed) 86 | rt &= checkTestNum('FAILED', len(failed), failedNum) 87 | rt &= checkTestDetail("FAILED", testDetail, failed) 88 | rt &= checkTestNum('DISABLED', len(disabled), disabledNum) 89 | rt &= checkTestDetail("DISABLED", testDetail, disabled) 90 | rt &= checkTestNum('SKIPPED', len(skipped), skippedNum) 91 | rt &= checkTestNum('TOTAL', len(passed) + len(failed) + len(disabled) + len(skipped), totalNum) 92 | rt &= checkTestNum('EXECUTED', len(passed) + len(failed), exectuedNum) 93 | 94 | if not rt: 95 | print("\tTest failed!") 96 | return False 97 | else: 98 | print("\tTest successful!") 99 | return True -------------------------------------------------------------------------------- /src/org/openj9/envInfo/CmdExecutor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.openj9.envInfo; 16 | 17 | import java.io.BufferedReader; 18 | import java.io.IOException; 19 | import java.io.InputStreamReader; 20 | import java.util.Arrays; 21 | import java.util.Map; 22 | 23 | public class CmdExecutor { 24 | private static CmdExecutor instance; 25 | 26 | private CmdExecutor() { 27 | } 28 | 29 | public static CmdExecutor getInstance() { 30 | if (instance == null) { 31 | instance = new CmdExecutor(); 32 | } 33 | return instance; 34 | } 35 | 36 | public String execute(String[] commands) { 37 | String rt = null; 38 | try { 39 | ProcessBuilder builder = new ProcessBuilder(Arrays.asList(commands)); 40 | Map env = builder.environment(); 41 | // clear env and copy from the parent shell environment 42 | env.clear(); 43 | Map shellEnv = System.getenv(); 44 | env.putAll(shellEnv); 45 | builder.redirectErrorStream(true); 46 | Process proc = builder.start(); 47 | BufferedReader stdOutput = new BufferedReader(new InputStreamReader(proc.getInputStream())); 48 | 49 | StringBuilder sb = new StringBuilder(); 50 | String line = null; 51 | String newline = ""; 52 | while ((line = stdOutput.readLine()) != null) { 53 | sb.append(newline).append(line); 54 | newline = "\n"; 55 | } 56 | rt = sb.toString(); 57 | proc.waitFor(); 58 | } catch (IOException | InterruptedException e) { 59 | return "Command could not be executed"; 60 | } 61 | return rt; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/org/openj9/envInfo/EnvDetector.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.openj9.envInfo; 16 | 17 | import java.io.IOException; 18 | import java.io.Writer; 19 | 20 | public class EnvDetector { 21 | static boolean isMachineInfo = false; 22 | static boolean isJavaInfo = false; 23 | static MachineInfo machineInfo = null; 24 | 25 | public static void main(String[] args) { 26 | parseArgs(args); 27 | } 28 | 29 | private static void parseArgs(String[] args) { 30 | machineInfo = new MachineInfo(); 31 | machineInfo.checkInfo(); 32 | if (args.length == 0) { 33 | printMachineInfo(); 34 | getJavaInfo(); 35 | } 36 | for (int i = 0; i < args.length; i++) { 37 | String option = args[i].toLowerCase(); 38 | if (option.equals("machineinfo")) { 39 | printMachineInfo(); 40 | } else if (option.equals("javainfo")) { 41 | getJavaInfo(); 42 | } 43 | } 44 | } 45 | 46 | /* 47 | * getJavaInfo() is used for AUTO_DETECT 48 | */ 49 | private static void getJavaInfo() { 50 | 51 | JavaInfo envDetection = new JavaInfo(); 52 | String javaImplInfo = envDetection.getJDKImpl(); 53 | String vendorInfo = envDetection.getJDKVendor(); 54 | String SPECInfo = envDetection.getSPEC(javaImplInfo); 55 | String javaVersion = envDetection.getJavaVersion(); 56 | String testFlag = envDetection.getTestFlag(); 57 | int javaVersionInfo = envDetection.getJDKVersion(); 58 | String releaseInfo = envDetection.getReleaseInfo(); 59 | if (SPECInfo == null || javaVersionInfo == -1 || javaImplInfo == null) { 60 | System.exit(1); 61 | } 62 | String MICRO_ARCH = ""; 63 | if (machineInfo.getInfoMap().containsKey("microArch")) { 64 | MICRO_ARCH = "DETECTED_MICRO_ARCH=" + machineInfo.getInfoMap().get("microArch").output + "\n"; 65 | } 66 | String OS_LABEL = ""; 67 | if (machineInfo.getInfoMap().containsKey("osLabel")) { 68 | OS_LABEL = "DETECTED_OS_LABEL=" + machineInfo.getInfoMap().get("osLabel").output + "\n"; 69 | } 70 | String SPEC = "DETECTED_SPEC=" + SPECInfo + "\n"; 71 | String JDK_VERSION = "DETECTED_JDK_VERSION=" + javaVersionInfo + "\n"; 72 | String JDK_IMPL = "DETECTED_JDK_IMPL=" + javaImplInfo + "\n"; 73 | String JDK_VENDOR = "DETECTED_JDK_VENDOR=" + vendorInfo + "\n"; 74 | String JAVA_VERSION = "DETECTED_JAVA_VERSION=" + javaVersion + "\n"; 75 | String RELEASE_INFO = "DETECTED_RELEASE_INFO=" + releaseInfo + "\n"; 76 | String TEST_FLAG = "DETECTED_TEST_FLAG=" + testFlag + "\n"; 77 | 78 | /** 79 | * autoGenEnv.mk file will be created to store auto detected java info. 80 | */ 81 | Writer output = null; 82 | try { 83 | output = Utility.getWriterObject(javaVersionInfo, SPECInfo, "autoGenEnv.mk"); 84 | output.write("########################################################\n"); 85 | output.write("# This is an auto generated file. Please do NOT modify!\n"); 86 | output.write("########################################################\n"); 87 | output.write(SPEC); 88 | output.write(MICRO_ARCH); 89 | output.write(OS_LABEL); 90 | output.write(JDK_VERSION); 91 | output.write(JDK_IMPL); 92 | output.write(JDK_VENDOR); 93 | output.write(TEST_FLAG); 94 | output.close(); 95 | output = Utility.getWriterObject(javaVersionInfo, SPECInfo, "AQACert.log"); 96 | output.write(JAVA_VERSION); 97 | output.write(RELEASE_INFO); 98 | output.close(); 99 | } catch (IOException e) { 100 | e.printStackTrace(); 101 | } 102 | } 103 | 104 | private static void printMachineInfo() { 105 | System.out.println("****************************** MACHINE INFO ******************************"); 106 | System.out.println(machineInfo); 107 | System.out.println("**************************************************************************\n"); 108 | } 109 | } -------------------------------------------------------------------------------- /src/org/openj9/envInfo/Info.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.openj9.envInfo; 16 | 17 | public class Info { 18 | public String name; 19 | public String[] cmds; 20 | public String output; 21 | public String req; 22 | 23 | public Info(String name, String[] cmds, String output, String req) { 24 | this.name = name; 25 | this.cmds = cmds; 26 | this.output = output; 27 | this.req = req; 28 | } 29 | } -------------------------------------------------------------------------------- /src/org/openj9/envInfo/Utility.java: -------------------------------------------------------------------------------- 1 | package org.openj9.envInfo; 2 | 3 | import java.io.FileOutputStream; 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | import java.io.OutputStreamWriter; 7 | import java.io.Writer; 8 | import java.nio.charset.Charset; 9 | 10 | public class Utility { 11 | 12 | public static Writer writer; 13 | 14 | public static Writer getWriterObject(int jdkVersion, String SpecInfo, String fileName) { 15 | try { 16 | if (SpecInfo.toLowerCase().contains("zos") && (jdkVersion >= 21)) { 17 | writer = new OutputStreamWriter(new FileOutputStream(fileName, true), Charset.forName("IBM-1047")); 18 | } else { 19 | writer = new FileWriter(fileName, true); 20 | } 21 | } catch(IOException e) { 22 | e.printStackTrace(); 23 | System.exit(1); 24 | } 25 | return writer; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/org/testKitGen/BuildList.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.io.IOException; 19 | import java.io.Writer; 20 | import java.nio.file.Path; 21 | import java.nio.file.Paths; 22 | import java.util.HashSet; 23 | import java.util.Set; 24 | 25 | import org.openj9.envInfo.JavaInfo; 26 | import org.openj9.envInfo.Utility; 27 | 28 | public class BuildList { 29 | private Arguments arg; 30 | private JavaInfo jInfo; 31 | private Set originalSet = new HashSet<>(); 32 | private Set newSet = new HashSet<>(); 33 | private String buildInfomk; 34 | 35 | public BuildList(Arguments arg) { 36 | this.arg = arg; 37 | this.jInfo = new JavaInfo(); 38 | buildInfomk = arg.getProjectRootDir() + "/TKG/" + Constants.BUILDINFOMK; 39 | initializeSet(); 40 | } 41 | 42 | private void initializeSet() { 43 | if (!arg.getBuildList().isEmpty()) { 44 | String[] buildListArr = arg.getBuildList().split(","); 45 | for (String buildPath : buildListArr) { 46 | buildPath = buildPath.replaceAll("\\+", "/"); 47 | originalSet.add(buildPath); 48 | } 49 | } 50 | } 51 | 52 | public boolean isRelated(String dir) { 53 | if (originalSet.isEmpty()) { 54 | return true; 55 | } 56 | for (String buildPath : originalSet) { 57 | if (dir.equals(buildPath) || dir.equals("") || dir.contains(buildPath + "/") || buildPath.contains(dir + "/")) { 58 | return true; 59 | } 60 | } 61 | return false; 62 | } 63 | 64 | public boolean contains(String dir) { 65 | if (originalSet.isEmpty()) { 66 | return true; 67 | } 68 | for (String buildPath : originalSet) { 69 | if (dir.equals(buildPath) || dir.contains(buildPath + "/")) { 70 | return true; 71 | } 72 | } 73 | return false; 74 | } 75 | 76 | public void add(File playlistXML) { 77 | Path basePath = Paths.get(arg.getProjectRootDir()); 78 | Path playlistPath = playlistXML.toPath(); 79 | Path relativePath = basePath.relativize(playlistPath); 80 | newSet.add(relativePath.getParent().toString().replace('\\', '/')); 81 | } 82 | 83 | private String getStr() { 84 | Set s = newSet; 85 | if (arg.getTestTargetName().equals("compile")) { 86 | s = originalSet; 87 | } else if (newSet.isEmpty()) { 88 | newSet.add("NULL"); 89 | } 90 | StringBuilder sb = new StringBuilder(); 91 | String sep = ""; 92 | for (String buildPath : s) { 93 | sb.append(sep).append(buildPath); 94 | sep =","; 95 | } 96 | return sb.toString(); 97 | } 98 | 99 | public void generateList() { 100 | try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), buildInfomk)) { 101 | f.write(Constants.HEADERCOMMENTS); 102 | f.write("REFINED_BUILD_LIST := " + getStr() + "\n"); 103 | System.out.println("Generated " + buildInfomk + "\n"); 104 | } catch (IOException e) { 105 | e.printStackTrace(); 106 | System.exit(1); 107 | } 108 | } 109 | 110 | public void clean() { 111 | File f = new File(buildInfomk); 112 | f.delete(); 113 | } 114 | } -------------------------------------------------------------------------------- /src/org/testKitGen/BuildListGenVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.util.List; 19 | 20 | public class BuildListGenVisitor implements DirectoryVisitor { 21 | private Arguments arg; 22 | private ModesDictionary md; 23 | private TestTarget tt; 24 | private BuildList bl; 25 | 26 | public BuildListGenVisitor(Arguments arg, ModesDictionary md, TestTarget tt, BuildList bl) { 27 | this.arg = arg; 28 | this.md = md; 29 | this.tt = tt; 30 | this.bl = bl; 31 | } 32 | 33 | @Override 34 | public boolean visit(File playlistXML, String absoluteDir, List dirList, List subDirs, List ignoreOnRerunList) { 35 | PlaylistInfoParser parser = new PlaylistInfoParser(arg, md, tt, playlistXML, bl); 36 | parser.parse(); 37 | return true; 38 | } 39 | } -------------------------------------------------------------------------------- /src/org/testKitGen/CleanVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.util.List; 19 | 20 | public class CleanVisitor implements DirectoryVisitor { 21 | 22 | public CleanVisitor() { 23 | } 24 | 25 | @Override 26 | public boolean visit(File playlistXML, String absoluteDir, List dirList, List subDirs, List ignoreOnRerunList) { 27 | String makeFile = absoluteDir + "/" + Constants.TESTMK; 28 | File file = new File(makeFile); 29 | file.delete(); 30 | return true; 31 | } 32 | } -------------------------------------------------------------------------------- /src/org/testKitGen/Constants.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.util.List; 18 | import java.util.Set; 19 | import java.util.stream.Collectors; 20 | import java.util.Arrays; 21 | 22 | public final class Constants { 23 | public static final String PLAYLIST = "playlist.xml"; 24 | public static final String RESOURCE = "resources"; 25 | public static final String MODESXML = Constants.RESOURCE + "/modes.xml"; 26 | public static final String OTTAWACSV = Constants.RESOURCE + "/ottawa.csv"; 27 | public static final String PLAYLISTXSD = Constants.RESOURCE + "/playlist.xsd"; 28 | public static final String BUILDPLAT_JSON = Constants.RESOURCE + "/buildPlatformMap.properties"; 29 | public static final String TRSSCACHE_DIR = Constants.RESOURCE + "/TRSS"; 30 | public static final String TESTMK = "autoGen.mk"; 31 | public static final String UTILSMK = "utils.mk"; 32 | public static final String RERUNMK = "rerun.mk"; 33 | public static final String SETTINGSMK = "settings.mk"; 34 | public static final String PARALLELMK = "parallelList.mk"; 35 | public static final String BUILDINFOMK = "buildInfo.mk"; 36 | public static final String HEADERCOMMENTS = "########################################################\n" 37 | + "# This is an auto generated file. Please do NOT modify!\n" 38 | + "########################################################\n\n"; 39 | public static final List ALLGROUPS = Arrays.asList("functional", "openjdk", "external", "perf", "jck", 40 | "system"); 41 | public static final List ALLIMPLS = Arrays.asList("openj9", "ibm", "hotspot", "sap"); 42 | public static final List ALLLEVELS = Arrays.asList("sanity", "extended", "special", "dev"); 43 | public static final List ALLTYPES = Arrays.asList("regular", "native"); 44 | public static final Set INGORESPECS = Arrays 45 | .asList("linux_x86-32_hrt", "linux_x86-64_cmprssptrs_gcnext", "linux_ppc_purec", "linux_ppc-64_purec", 46 | "linux_ppc-64_cmprssptrs_purec", "linux_x86-64_cmprssptrs_cloud") 47 | .stream().collect(Collectors.toSet()); 48 | public static final String TRSS_URL = "https://trss.adoptopenjdk.net"; 49 | private Constants() { 50 | } 51 | } -------------------------------------------------------------------------------- /src/org/testKitGen/DirectoryVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.util.List; 19 | 20 | public interface DirectoryVisitor { 21 | public boolean visit(File playlistXML, String absoluteDir, List dirList, List subDirs, List ignoreOnRerunList); 22 | } -------------------------------------------------------------------------------- /src/org/testKitGen/DirectoryWalker.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class DirectoryWalker { 22 | private Arguments arg; 23 | private DirectoryVisitor dv; 24 | private BuildList bl; 25 | private ArrayList dirList; 26 | private List ignoreOnRerunList; 27 | 28 | public DirectoryWalker(Arguments arg, DirectoryVisitor dv, BuildList bl, List ignoreOnRerunList) { 29 | this.arg = arg; 30 | this.dv = dv; 31 | this.bl = bl; 32 | this.ignoreOnRerunList = ignoreOnRerunList; 33 | dirList = new ArrayList(); 34 | } 35 | 36 | public boolean traverse() { 37 | String absoluteDir = arg.getProjectRootDir(); 38 | String currentDir = String.join("/", dirList); 39 | if (!dirList.isEmpty()) { 40 | absoluteDir = absoluteDir + '/' + currentDir; 41 | } 42 | 43 | if (!bl.isRelated(currentDir)) { 44 | return false; 45 | } 46 | 47 | File playlistXML = null; 48 | 49 | File directory = new File(absoluteDir); 50 | File[] dir = directory.listFiles(); 51 | List subDirsWithTest = new ArrayList(); 52 | for (File entry : dir) { 53 | File file = new File(absoluteDir + '/' + entry.getName()); 54 | if (bl.contains(currentDir) && file.isFile() && entry.getName().equals(Constants.PLAYLIST)) { 55 | playlistXML = file; 56 | } else if (file.isDirectory()) { 57 | dirList.add(entry.getName()); 58 | if (traverse()) { 59 | subDirsWithTest.add(entry.getName()); 60 | } 61 | dirList.remove(dirList.size() - 1); 62 | } 63 | } 64 | 65 | boolean rt = dv.visit(playlistXML, absoluteDir, dirList, subDirsWithTest, ignoreOnRerunList); 66 | return rt; 67 | } 68 | } -------------------------------------------------------------------------------- /src/org/testKitGen/MainRunner.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | package org.testKitGen; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import java.util.Map; 19 | public class MainRunner { 20 | 21 | private MainRunner() { 22 | } 23 | 24 | public static void main(String[] args) { 25 | Arguments argInfo = Arguments.getInstance(); 26 | argInfo.parse(args); 27 | BuildList bl = new BuildList(argInfo); 28 | if (argInfo.getMode() == Arguments.Mode.CLEAN) { 29 | clean(argInfo, bl); 30 | } else { 31 | TestTarget tt = TestTarget.getInstance(); 32 | tt.parse(argInfo.getTestTargetName(), argInfo.getTestList()); 33 | ModesDictionary md = new ModesDictionary(argInfo); 34 | md.parse(); 35 | if (argInfo.getMode() == Arguments.Mode.GEN_TESTS) { 36 | genTests(argInfo, md, tt, bl); 37 | } else if (argInfo.getMode() == Arguments.Mode.GEN_PARALLEL_LIST) { 38 | genParallelList(argInfo, md, tt, bl); 39 | } else if (argInfo.getMode() == Arguments.Mode.GEN_BUILD_LIST) { 40 | genBuildList(argInfo, md, tt, bl); 41 | } 42 | if (!tt.isCategory()) { 43 | String testsNotFound = ""; 44 | String separator = ""; 45 | for (Map.Entry entry : tt.getTestList().getTestMap().entrySet()) { 46 | if (!entry.getValue()) { 47 | testsNotFound += separator + entry.getKey(); 48 | separator = ", "; 49 | } 50 | } 51 | if (!testsNotFound.isEmpty()) { 52 | System.err.println("Error: cannot find the following tests: " + testsNotFound + " (note: group target such as sanity is not accepted inside testList)\n"); 53 | System.exit(1); 54 | } 55 | } 56 | } 57 | } 58 | 59 | public static void genTests(Arguments argInfo, ModesDictionary md, TestTarget tt, BuildList bl) { 60 | System.out.println("Starting to generate test make files.\n"); 61 | List ignoreOnRerunList = new ArrayList<>(); 62 | DirectoryWalker dw = new DirectoryWalker(argInfo, new TestGenVisitor(argInfo, md, tt), bl, ignoreOnRerunList); 63 | dw.traverse(); 64 | UtilsGen ug = new UtilsGen(argInfo, md, ignoreOnRerunList); 65 | ug.generateFiles(); 66 | System.out.println("Make files are generated successfully.\n"); 67 | } 68 | 69 | public static void genParallelList(Arguments argInfo, ModesDictionary md, TestTarget tt, BuildList bl) { 70 | System.out.println("\nStarting to generate parallel test lists.\n"); 71 | DirectoryWalker dw = new DirectoryWalker(argInfo, new ParallelGenVisitor(argInfo, md, tt), bl, null); 72 | dw.traverse(); 73 | TestDivider td = new TestDivider(argInfo, tt); 74 | td.generateLists(); 75 | } 76 | 77 | public static void genBuildList(Arguments argInfo, ModesDictionary md, TestTarget tt, BuildList bl) { 78 | System.out.println("\nStarting to generate build list.\n"); 79 | DirectoryWalker dw = new DirectoryWalker(argInfo, new BuildListGenVisitor(argInfo, md, tt, bl), bl, null); 80 | dw.traverse(); 81 | bl.generateList(); 82 | } 83 | 84 | public static void clean(Arguments argInfo, BuildList bl) { 85 | DirectoryWalker dw = new DirectoryWalker(argInfo, new CleanVisitor(), bl, null); 86 | dw.traverse(); 87 | UtilsGen ug = new UtilsGen(argInfo, null, null); 88 | ug.clean(); 89 | TestDivider td = new TestDivider(argInfo, null); 90 | td.clean(); 91 | bl.clean(); 92 | System.out.println("\nGenerated makefiles are successfully removed\n"); 93 | } 94 | } -------------------------------------------------------------------------------- /src/org/testKitGen/ModesDictionary.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.BufferedReader; 18 | import java.io.IOException; 19 | import java.nio.charset.Charset; 20 | import java.nio.file.Files; 21 | import java.nio.file.Paths; 22 | import java.util.ArrayList; 23 | import java.util.Arrays; 24 | import java.util.HashMap; 25 | import java.util.List; 26 | import java.util.Map; 27 | import java.util.stream.Collectors; 28 | 29 | import javax.xml.parsers.DocumentBuilderFactory; 30 | import javax.xml.parsers.ParserConfigurationException; 31 | 32 | import org.openj9.envInfo.JavaInfo; 33 | import org.w3c.dom.Element; 34 | import org.w3c.dom.NodeList; 35 | import org.xml.sax.SAXException; 36 | 37 | public class ModesDictionary { 38 | private Arguments arg; 39 | private JavaInfo jInfo; 40 | private String modesXml; 41 | private String ottawaCsv; 42 | private Map spec2platMap; 43 | private Map> invalidSpecsMap; 44 | private Map clArgsMap; 45 | private String spec; 46 | 47 | public ModesDictionary(Arguments arg) { 48 | this.arg = arg; 49 | jInfo = new JavaInfo(); 50 | modesXml= arg.getProjectRootDir() + "/TKG/" + Constants.MODESXML; 51 | ottawaCsv = arg.getProjectRootDir() + "/TKG/" + Constants.OTTAWACSV; 52 | spec2platMap = new HashMap(); 53 | invalidSpecsMap = new HashMap>(); 54 | clArgsMap = new HashMap(); 55 | } 56 | 57 | public void parse() { 58 | try { 59 | Element modes = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(modesXml) 60 | .getDocumentElement(); 61 | parseMode(modes); 62 | parseInvalidSpec(modes); 63 | } catch (SAXException | IOException | ParserConfigurationException e) { 64 | e.printStackTrace(); 65 | System.exit(1); 66 | } 67 | System.out.println("Modes data parsed from " + Constants.MODESXML + " and " + Constants.OTTAWACSV + ".\n"); 68 | } 69 | 70 | private void parseMode(Element modes) { 71 | NodeList modesNodes = modes.getElementsByTagName("mode"); 72 | for (int i = 0; i < modesNodes.getLength(); i++) { 73 | Element mode = (Element) modesNodes.item(i); 74 | StringBuilder sb = new StringBuilder(); 75 | NodeList clArgsNodes = mode.getElementsByTagName("clArg"); 76 | for (int j = 0; j < clArgsNodes.getLength(); j++) { 77 | sb.append(clArgsNodes.item(j).getTextContent().trim()).append(" "); 78 | } 79 | clArgsMap.put(mode.getAttribute("number"), sb.toString().trim()); 80 | } 81 | } 82 | 83 | private void setSpec() { 84 | String originalSpec = arg.getSpec(); 85 | if (spec2platMap.containsKey(originalSpec)) { 86 | spec = originalSpec; 87 | } else { 88 | System.out.println("\nWarning: cannot find spec in " + Constants.OTTAWACSV + "."); 89 | if (originalSpec.contains("64")) { 90 | spec = "default-64"; 91 | System.out.print("\tDetected 64 in spec. "); 92 | } else { 93 | spec = "default-none64"; 94 | System.out.print("\tDidn't detect 64 in spec. "); 95 | } 96 | System.out.println("Use spec: " + spec + " to match mode.\n"); 97 | } 98 | } 99 | 100 | private void parseInvalidSpec(Element modes) throws IOException { 101 | ArrayList specs = new ArrayList(); 102 | int lineNum = 0; 103 | BufferedReader reader = null; 104 | if (arg.getSpec().toLowerCase().contains("zos") && !(jInfo.getJDKVersion() >= 21)) { 105 | reader = Files.newBufferedReader(Paths.get(ottawaCsv), Charset.forName("IBM-1047")); 106 | } else { 107 | reader = Files.newBufferedReader(Paths.get(ottawaCsv)); 108 | } 109 | String line = reader.readLine(); 110 | while (line != null) { 111 | String[] fields = line.split(","); 112 | // Since the spec line has an empty title, we cannot do string match. We assume 113 | // the second line is spec. 114 | if (lineNum++ == 1) { 115 | specs.addAll(Arrays.asList(fields)); 116 | } else if (fields[0].equals("plat")) { 117 | for (int i = 1; i < fields.length; i++) { 118 | spec2platMap.put(specs.get(i), fields[i]); 119 | } 120 | } else if (fields[0].startsWith("variation:")) { 121 | String modeNum = fields[0].substring("variation:".length()); 122 | 123 | // Remove string Mode if it exists 124 | modeNum = modeNum.replace("Mode", ""); 125 | 126 | NodeList modesNodes = modes.getElementsByTagName("mode"); 127 | 128 | for (int i = 0; i < modesNodes.getLength(); i++) { 129 | Element mode = (Element) modesNodes.item(i); 130 | if (mode.getAttribute("number").equals(modeNum)) { 131 | ArrayList invalidSpecs = new ArrayList(); 132 | for (int j = 1; j < fields.length; j++) { 133 | if (fields[j].equals("no")) { 134 | invalidSpecs.add(specs.get(j)); 135 | } 136 | } 137 | // remove INGORESPECS from invalidSpecs array 138 | invalidSpecs = new ArrayList(invalidSpecs.stream() 139 | .filter(c -> !Constants.INGORESPECS.contains(c)).collect(Collectors.toList())); 140 | // if invalidSpecs array is empty, set it to none 141 | if (invalidSpecs.size() == 0) { 142 | invalidSpecs.add("none"); 143 | } 144 | invalidSpecsMap.put(modeNum, invalidSpecs); 145 | break; 146 | } 147 | } 148 | } 149 | line = reader.readLine(); 150 | } 151 | setSpec(); 152 | } 153 | 154 | public String getClArgs(String mode) { 155 | String rt = ""; 156 | if (clArgsMap.containsKey(mode)) { 157 | rt = clArgsMap.get(mode); 158 | } else { 159 | System.out.println("\nWarning: cannot find mode " + mode + " to fetch jvm options"); 160 | } 161 | return rt; 162 | } 163 | 164 | public boolean isValidMode(String mode) { 165 | boolean rt = true; 166 | // It is normal that certain mode cannot be found in ottawa.csv, in which case 167 | // it means no invalid specs 168 | if (invalidSpecsMap.containsKey(mode)) { 169 | rt = !invalidSpecsMap.get(mode).contains(spec); 170 | } 171 | return rt; 172 | } 173 | 174 | public String getPlat() { 175 | String rt = ""; 176 | if (spec2platMap.containsKey(spec)) { 177 | rt = spec2platMap.get(spec); 178 | } 179 | return rt; 180 | } 181 | } -------------------------------------------------------------------------------- /src/org/testKitGen/ParallelGenVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.util.List; 19 | 20 | public class ParallelGenVisitor implements DirectoryVisitor { 21 | private Arguments arg; 22 | private ModesDictionary md; 23 | private TestTarget tt; 24 | 25 | public ParallelGenVisitor(Arguments arg, ModesDictionary md, TestTarget tt) { 26 | this.arg = arg; 27 | this.md = md; 28 | this.tt = tt; 29 | } 30 | 31 | @Override 32 | public boolean visit(File playlistXML, String absoluteDir, List dirList, List subDirs, List ignoreOnRerunList) { 33 | PlaylistInfoParser parser = new PlaylistInfoParser(arg, md, tt, playlistXML); 34 | parser.parse(); 35 | return true; 36 | } 37 | } -------------------------------------------------------------------------------- /src/org/testKitGen/PlaylistInfo.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class PlaylistInfo { 20 | private List testInfoList; 21 | private List includeList; 22 | private List ignoreOnRerunList; 23 | 24 | public PlaylistInfo() { 25 | this.includeList = new ArrayList(); 26 | this.testInfoList = new ArrayList(); 27 | this.ignoreOnRerunList = new ArrayList(); 28 | } 29 | 30 | public List getIncludeList() { 31 | return includeList; 32 | } 33 | 34 | public void addInclude(String include) { 35 | this.includeList.add(include); 36 | } 37 | 38 | public List getTestInfoList() { 39 | return testInfoList; 40 | } 41 | 42 | public void setTestInfoList(List testInfoList) { 43 | this.testInfoList = testInfoList; 44 | } 45 | 46 | public void addIgnoreOnRerun(String test) { 47 | ignoreOnRerunList.add(test); 48 | } 49 | 50 | public List getIgnoreOnRerunList() { 51 | return this.ignoreOnRerunList; 52 | } 53 | 54 | public boolean containsTest() { 55 | return getTestInfoList().size() > 0; 56 | } 57 | } -------------------------------------------------------------------------------- /src/org/testKitGen/PlaylistInfoParser.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.io.IOException; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import javax.xml.parsers.DocumentBuilderFactory; 23 | import javax.xml.parsers.ParserConfigurationException; 24 | import javax.xml.validation.SchemaFactory; 25 | import javax.xml.validation.Validator; 26 | import javax.xml.XMLConstants; 27 | import javax.xml.transform.stream.StreamSource; 28 | 29 | import org.w3c.dom.Document; 30 | import org.w3c.dom.Element; 31 | import org.w3c.dom.Node; 32 | import org.w3c.dom.NodeList; 33 | import org.xml.sax.SAXException; 34 | import org.xml.sax.SAXParseException; 35 | import org.xml.sax.helpers.DefaultHandler; 36 | 37 | public class PlaylistInfoParser { 38 | private Arguments arg; 39 | private ModesDictionary md; 40 | private TestTarget tt; 41 | private File playlistXML; 42 | private File playlistXSD; 43 | private BuildList bl; 44 | 45 | public PlaylistInfoParser(Arguments arg, ModesDictionary md, TestTarget tt, File playlistXML) { 46 | this.arg = arg; 47 | this.md = md; 48 | this.tt = tt; 49 | this.playlistXML = playlistXML; 50 | this.playlistXSD = new File(Constants.PLAYLISTXSD); 51 | } 52 | 53 | private static class xsdErrorHandler extends DefaultHandler { 54 | @Override 55 | public void warning(SAXParseException e) throws SAXException { 56 | throw e; 57 | } 58 | 59 | @Override 60 | public void error(SAXParseException e) throws SAXException { 61 | throw e; 62 | } 63 | 64 | @Override 65 | public void fatalError(SAXParseException e) throws SAXException { 66 | throw e; 67 | } 68 | } 69 | 70 | private void validate() { 71 | if (playlistXML != null) { 72 | try { 73 | Validator validator = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(playlistXSD).newValidator(); 74 | validator.setErrorHandler(new xsdErrorHandler()); 75 | validator.validate(new StreamSource(playlistXML)); 76 | } catch (SAXParseException e) { 77 | System.err.println("Error: schema validation failed for " + playlistXML.getAbsolutePath() + " with exception:"); 78 | System.err.println("Line: " + e.getLineNumber()); 79 | System.err.println("Column: " + e.getColumnNumber()); 80 | System.err.println("Message: " + e.getMessage()); 81 | System.exit(1); 82 | } catch (Exception e) { 83 | e.printStackTrace(); 84 | System.exit(1); 85 | } 86 | } 87 | } 88 | 89 | public PlaylistInfoParser(Arguments arg, ModesDictionary md, TestTarget tt, File playlistXML, BuildList bl) { 90 | this.arg = arg; 91 | this.md = md; 92 | this.tt = tt; 93 | this.playlistXML = playlistXML; 94 | this.bl = bl; 95 | this.playlistXSD = new File(Constants.PLAYLISTXSD); 96 | } 97 | 98 | public PlaylistInfo parse() { 99 | validate(); 100 | PlaylistInfo pli = new PlaylistInfo(); 101 | if (playlistXML == null) return pli; 102 | try { 103 | System.out.println("Parsing " + playlistXML.getAbsolutePath()); 104 | Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(playlistXML); 105 | NodeList childNodes = xml.getDocumentElement().getChildNodes(); 106 | List testInfoList = new ArrayList(); 107 | for (int i = 0; i < childNodes.getLength(); i++) { 108 | Node currentNode = childNodes.item(i); 109 | if (currentNode.getNodeType() == Node.ELEMENT_NODE) { 110 | Element currentElement = ((Element) currentNode); 111 | if (currentElement.getNodeName().equals("include")) { 112 | pli.addInclude(currentElement.getTextContent()); 113 | } else if (currentElement.getNodeName().equals("test")) { 114 | TestInfoParser parser = new TestInfoParser(arg, md, currentElement, tt); 115 | TestInfo ti = parser.parse(); 116 | if (ti != null) { 117 | testInfoList.add(ti); 118 | int previousTestsToExecute = TestInfo.getTestsToExecute().size(); 119 | TestInfo.countTests(ti, tt); 120 | if ((previousTestsToExecute < TestInfo.getTestsToExecute().size()) && (bl != null)) { 121 | bl.add(playlistXML); 122 | } 123 | if (!ti.getRerun()) { 124 | for (Variation var : ti.getVars()) { 125 | pli.addIgnoreOnRerun(var.getSubTestName()); 126 | } 127 | } 128 | } 129 | } 130 | } 131 | } 132 | pli.setTestInfoList(testInfoList); 133 | } catch (SAXException | IOException | ParserConfigurationException e) { 134 | e.printStackTrace(); 135 | System.exit(1); 136 | } 137 | return pli; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/org/testKitGen/TestCategory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashSet; 19 | import java.util.List; 20 | import java.util.Set; 21 | 22 | public class TestCategory { 23 | enum Prefix { 24 | REGULAR, DISABLED, ECHODISABLED; 25 | } 26 | 27 | private Set categorySet = new HashSet(); 28 | private Prefix prefix = Prefix.REGULAR; 29 | private static TestCategory instance; 30 | 31 | private TestCategory() { 32 | } 33 | 34 | public static TestCategory getInstance() { 35 | if (instance == null) { 36 | instance = new TestCategory(); 37 | } 38 | return instance; 39 | } 40 | 41 | public void filter(TestInfo testInfo) { 42 | List> allCategories = new ArrayList<>(); 43 | allCategories.add(testInfo.getGroups()); 44 | allCategories.add(testInfo.getTypes()); 45 | allCategories.add(testInfo.getLevels()); 46 | 47 | int found = 0; 48 | for (List cat : allCategories) { 49 | for (String s : cat) { 50 | if (categorySet.contains(s)) { 51 | found++; 52 | break; 53 | } 54 | } 55 | } 56 | if (found == allCategories.size()) { 57 | for (Variation var : testInfo.getVars()) { 58 | if (prefix == Prefix.REGULAR) { 59 | if (var.isDisabled()) { 60 | var.setStatus(Variation.PrintStatus.PRINT_DISABLED); 61 | } else { 62 | var.setStatus(Variation.PrintStatus.PRINT_CMD); 63 | } 64 | } else if (prefix == Prefix.DISABLED) { 65 | if (var.isDisabled()) { 66 | var.setStatus(Variation.PrintStatus.PRINT_CMD); 67 | } else { 68 | var.setStatus(Variation.PrintStatus.DO_NOT_PRINT); 69 | } 70 | var.setPrefix("disabled."); 71 | } else if (prefix == Prefix.ECHODISABLED) { 72 | if (var.isDisabled()) { 73 | var.setStatus(Variation.PrintStatus.PRINT_DISABLED); 74 | } else { 75 | var.setStatus(Variation.PrintStatus.DO_NOT_PRINT); 76 | } 77 | var.setPrefix("echo.disabled."); 78 | } 79 | } 80 | } 81 | } 82 | 83 | public Set getCategorySet() { 84 | return categorySet; 85 | } 86 | 87 | public boolean parseTarget(String target) { 88 | String strippedTarget = target; 89 | if (target.startsWith("echo.disabled.")) { 90 | prefix = Prefix.ECHODISABLED; 91 | strippedTarget = target.substring(new String("echo.disabled.").length()); 92 | } else if (target.startsWith("disabled.")) { 93 | prefix = Prefix.DISABLED; 94 | strippedTarget = target.substring(new String("disabled.").length()); 95 | } 96 | 97 | Set potentialSet = new HashSet(); 98 | List> sets = new ArrayList>(); 99 | sets.add(new HashSet(Constants.ALLLEVELS)); 100 | sets.add(new HashSet(Constants.ALLGROUPS)); 101 | sets.add(new HashSet(Constants.ALLTYPES)); 102 | 103 | if (strippedTarget.equals("all") || strippedTarget.equals("")) { 104 | for (Set set : sets) { 105 | potentialSet.addAll(set); 106 | } 107 | } else { 108 | String[] targets = strippedTarget.split("\\."); 109 | int j = 0; 110 | for (int i = 0; i < sets.size(); i++) { 111 | if (j < targets.length && sets.get(i).contains(targets[j])) { 112 | potentialSet.add(targets[j]); 113 | j++; 114 | } else { 115 | potentialSet.addAll(sets.get(i)); 116 | } 117 | } 118 | if (j != targets.length) { 119 | return false; 120 | } 121 | } 122 | 123 | categorySet = potentialSet; 124 | return true; 125 | } 126 | } -------------------------------------------------------------------------------- /src/org/testKitGen/TestGenVisitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.util.List; 19 | 20 | public class TestGenVisitor implements DirectoryVisitor { 21 | private Arguments arg; 22 | private ModesDictionary md; 23 | private TestTarget tt; 24 | 25 | public TestGenVisitor(Arguments arg, ModesDictionary md, TestTarget tt) { 26 | this.arg = arg; 27 | this.md = md; 28 | this.tt = tt; 29 | } 30 | 31 | @Override 32 | public boolean visit(File playlistXML, String absoluteDir, List dirList, List subDirs, List ignoreOnRerunList) { 33 | PlaylistInfoParser parser = new PlaylistInfoParser(arg, md, tt, playlistXML); 34 | PlaylistInfo pli = parser.parse(); 35 | boolean testFound = !subDirs.isEmpty() || pli.containsTest(); 36 | String makeFile = absoluteDir + "/" + Constants.TESTMK; 37 | File file = new File(makeFile); 38 | file.delete(); 39 | if (testFound) { 40 | ignoreOnRerunList.addAll(pli.getIgnoreOnRerunList()); 41 | MkGen mg = new MkGen(arg, tt, pli, makeFile, dirList, subDirs); 42 | mg.start(); 43 | return true; 44 | } 45 | return false; 46 | } 47 | } -------------------------------------------------------------------------------- /src/org/testKitGen/TestInfo.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashMap; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class TestInfo { 23 | private String testCaseName; 24 | private String command; 25 | private String platform; 26 | private List platformRequirementsList; 27 | private List vars; 28 | private Map capabilities; 29 | private String aotOptions; 30 | private int aotIterations; 31 | private int iterations; 32 | private String levelStr; 33 | private Map features; 34 | private List levels; 35 | private List groups; 36 | private List types; 37 | private boolean rerun; 38 | private static List testsToExecute = new ArrayList<>(); 39 | private static List testsToDisplay = new ArrayList<>(); 40 | 41 | public TestInfo(Arguments arg) { 42 | this.testCaseName = null; 43 | this.command = null; 44 | this.platform = null; 45 | this.platformRequirementsList = new ArrayList(); 46 | this.vars = new ArrayList(); 47 | this.aotOptions = ""; 48 | this.aotIterations = arg.getAotIterations(); 49 | this.iterations = arg.getIterations(); 50 | this.capabilities = new HashMap(); 51 | this.levelStr = ""; 52 | this.features = new HashMap(); 53 | this.levels = new ArrayList(); 54 | this.groups = new ArrayList(); 55 | this.types = new ArrayList(); 56 | } 57 | 58 | public String getTestCaseName() { 59 | return this.testCaseName; 60 | } 61 | 62 | public void setTestCaseName(String testCaseName) { 63 | this.testCaseName = testCaseName; 64 | } 65 | 66 | public List getVars() { 67 | return this.vars; 68 | } 69 | 70 | public void setVars(List vars) { 71 | this.vars = vars; 72 | } 73 | 74 | public String getCommand() { 75 | return this.command; 76 | } 77 | 78 | public void setCommand(String command) { 79 | this.command = command; 80 | } 81 | 82 | public String getPlatform() { 83 | return this.platform; 84 | } 85 | 86 | public void setPlatform(String platform) { 87 | this.platform = platform; 88 | } 89 | 90 | public List getPlatformRequirementsList() { 91 | return this.platformRequirementsList; 92 | } 93 | 94 | public void addPlatformRequirements(String platformRequirements) { 95 | this.platformRequirementsList.add(platformRequirements); 96 | } 97 | 98 | public Map getCapabilities() { 99 | return this.capabilities; 100 | } 101 | 102 | public void setCapabilities(Map capabilities) { 103 | this.capabilities = capabilities; 104 | } 105 | 106 | public String getAotOptions() { 107 | return this.aotOptions; 108 | } 109 | 110 | public void setAotOptions(String aotOptions) { 111 | this.aotOptions = aotOptions; 112 | } 113 | 114 | public int getAotIterations() { 115 | return this.aotIterations; 116 | } 117 | 118 | public void setAotIterations(int aotIterations) { 119 | this.aotIterations = aotIterations; 120 | } 121 | 122 | public int getIterations() { 123 | return this.iterations; 124 | } 125 | 126 | public void setIterations(int iterations) { 127 | this.iterations = iterations; 128 | } 129 | 130 | public String getLevelStr() { 131 | return this.levelStr; 132 | } 133 | 134 | public void setLevelStr(String levelStr) { 135 | this.levelStr = levelStr; 136 | } 137 | 138 | public Map getFeatures() { 139 | return this.features; 140 | } 141 | 142 | public void addFeature(String key, String value) { 143 | this.features.put(key, value); 144 | } 145 | 146 | public List getLevels() { 147 | return this.levels; 148 | } 149 | 150 | public void setLevels(List levels) { 151 | this.levels = levels; 152 | } 153 | 154 | public List getGroups() { 155 | return this.groups; 156 | } 157 | 158 | public void setGroups(List groups) { 159 | this.groups = groups; 160 | } 161 | 162 | public List getTypes() { 163 | return this.types; 164 | } 165 | 166 | public void setTypes(List types) { 167 | this.types = types; 168 | } 169 | 170 | public void setRerun(boolean rerun) { 171 | this.rerun = rerun; 172 | } 173 | 174 | public boolean getRerun() { 175 | return this.rerun; 176 | } 177 | 178 | public static void countTests(TestInfo ti, TestTarget tt) { 179 | for (Variation var : ti.getVars()) { 180 | String testName = var.getPrefix() + var.getSubTestName(); 181 | if (var.isValid() && (var.getStatus() == Variation.PrintStatus.PRINT_CMD)) { 182 | testsToExecute.add(testName); 183 | } else if (var.getStatus() != Variation.PrintStatus.DO_NOT_PRINT) { 184 | testsToDisplay.add(testName); 185 | } 186 | } 187 | } 188 | 189 | public static List getTestsToExecute() { 190 | return testsToExecute; 191 | } 192 | 193 | public static List getTestsToDisplay() { 194 | return testsToDisplay; 195 | } 196 | 197 | public static int numOfTests() { 198 | return testsToExecute.size() + testsToDisplay.size(); 199 | } 200 | } -------------------------------------------------------------------------------- /src/org/testKitGen/TestList.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.util.Map; 18 | import java.util.Arrays; 19 | import java.util.HashMap; 20 | 21 | public class TestList { 22 | 23 | private String testList = null; 24 | private Map testMap = new HashMap(); 25 | private static TestList instance; 26 | 27 | private TestList() { 28 | } 29 | 30 | public static TestList getInstance() { 31 | if (instance == null) { 32 | instance = new TestList(); 33 | } 34 | return instance; 35 | } 36 | 37 | public void filter(TestInfo testInfo) { 38 | String name = testInfo.getTestCaseName(); 39 | String disabledName = "disabled." + name; 40 | String echoDisabledName = "echo.disabled." + name; 41 | 42 | for (Variation var : testInfo.getVars()){ 43 | String subName = var.getSubTestName(); 44 | String disabledSubName = "disabled." + subName; 45 | String echoDisabledSubName = "echo.disabled." + subName; 46 | String found = matchTarget(testMap, name, subName); 47 | if (found != null) { 48 | if (!var.isDisabled()) { 49 | var.setStatus(Variation.PrintStatus.PRINT_CMD); 50 | } else { 51 | var.setStatus(Variation.PrintStatus.PRINT_DISABLED); 52 | } 53 | testMap.replace(name, true); 54 | testMap.replace(subName, true); 55 | } 56 | String foundEchoDisabled = matchTarget(testMap, echoDisabledName, echoDisabledSubName); 57 | if (foundEchoDisabled != null) { 58 | if (var.isDisabled()) { 59 | var.setStatus(Variation.PrintStatus.PRINT_DISABLED); 60 | testMap.replace(echoDisabledName, true); 61 | testMap.replace(echoDisabledSubName, true); 62 | } 63 | var.setPrefix("echo.disabled."); 64 | } 65 | String foundDisabled = matchTarget(testMap, disabledName, disabledSubName); 66 | if (foundDisabled != null) { 67 | if (var.isDisabled()) { 68 | var.setStatus(Variation.PrintStatus.PRINT_CMD); 69 | testMap.replace(disabledName, true); 70 | testMap.replace(disabledSubName, true); 71 | } 72 | var.setPrefix("disabled."); 73 | } 74 | targetCheck(found, foundDisabled); 75 | targetCheck(foundEchoDisabled, foundDisabled); 76 | } 77 | } 78 | 79 | private void targetCheck(String target1, String target2) { 80 | if ((target1 != null) && (target2 != null)) { 81 | System.err.println("Error: testList contains contradictory target: " + target1 + " and " + target2 + "."); 82 | System.exit(1); 83 | } 84 | } 85 | 86 | private String matchTarget(Map testMap, String name, String subName) { 87 | if (testMap.containsKey(name)) { 88 | return name; 89 | } else if (testMap.containsKey(subName)) { 90 | return subName; 91 | } 92 | return null; 93 | } 94 | 95 | public Map getTestMap() { 96 | return testMap; 97 | } 98 | 99 | public void parseTarget(String list) { 100 | testList = list; 101 | String[] testListArr = testList.split(","); 102 | 103 | Arrays.sort(testListArr); 104 | for (String test : testListArr) { 105 | testMap.put(test, false); 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /src/org/testKitGen/TestTarget.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | public class TestTarget { 18 | enum Type { 19 | SINGLE, CATEGORY, LIST; 20 | } 21 | 22 | private String testTarget = null; 23 | private Type type = Type.SINGLE; 24 | private TestList tl = null; 25 | private TestCategory tc = null; 26 | private static TestTarget instance; 27 | 28 | private TestTarget() { 29 | tl = TestList.getInstance(); 30 | tc = TestCategory.getInstance(); 31 | } 32 | 33 | public static TestTarget getInstance() { 34 | if (instance == null) { 35 | instance = new TestTarget(); 36 | } 37 | return instance; 38 | } 39 | 40 | public String getTestTargetName() { 41 | return testTarget; 42 | } 43 | 44 | public boolean isCategory() { 45 | return type == Type.CATEGORY; 46 | } 47 | 48 | public boolean isSingleTest() { 49 | return type == Type.SINGLE; 50 | } 51 | 52 | public boolean isList() { 53 | return type == Type.LIST; 54 | } 55 | 56 | public TestList getTestList() { 57 | return tl; 58 | } 59 | 60 | public TestCategory getTestCategory() { 61 | return tc; 62 | } 63 | 64 | public boolean filterTestInfo(TestInfo testInfo) { 65 | switch (type) { 66 | case SINGLE: 67 | tl.filter(testInfo); 68 | break; 69 | case CATEGORY: 70 | tc.filter(testInfo); 71 | break; 72 | case LIST: 73 | tl.filter(testInfo); 74 | break; 75 | default: 76 | System.err.println("Invalid test type: " + type); 77 | } 78 | for (Variation var : testInfo.getVars()) { 79 | if (var.getStatus() != Variation.PrintStatus.DO_NOT_PRINT) { 80 | return true; 81 | } 82 | } 83 | return false; 84 | } 85 | 86 | public void parse(String target, String list) { 87 | testTarget = target; 88 | if (testTarget.equals("testList") && list != null) { 89 | tl.parseTarget(list); 90 | type = Type.LIST; 91 | } else if (tc.parseTarget(target)) { 92 | type = Type.CATEGORY; 93 | } else { 94 | //for single test, testList is the target 95 | tl.parseTarget(target); 96 | type = Type.SINGLE; 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /src/org/testKitGen/UtilsGen.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.io.File; 18 | import java.io.IOException; 19 | import java.io.Writer; 20 | import java.util.List; 21 | 22 | import org.openj9.envInfo.JavaInfo; 23 | import org.openj9.envInfo.Utility; 24 | 25 | 26 | public class UtilsGen { 27 | private Arguments arg; 28 | private ModesDictionary md; 29 | private JavaInfo jInfo; 30 | private String utilsMk; 31 | private String rerunMk; 32 | private List ignoreOnRerunList; 33 | 34 | public UtilsGen(Arguments arg, ModesDictionary md, List ignoreOnRerunList) { 35 | this.arg = arg; 36 | this.md = md; 37 | this.jInfo = new JavaInfo(); 38 | this.utilsMk = arg.getProjectRootDir() + "/TKG/" + Constants.UTILSMK; 39 | this.rerunMk = arg.getProjectRootDir() + "/TKG/" + Constants.RERUNMK; 40 | this.ignoreOnRerunList = ignoreOnRerunList; 41 | } 42 | 43 | public void generateFiles() { 44 | generateUtil(); 45 | generateRerun(); 46 | } 47 | 48 | private void generateUtil() { 49 | try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), utilsMk)) { 50 | f.write(Constants.HEADERCOMMENTS); 51 | f.write("TOTALCOUNT := " + TestInfo.numOfTests() + "\n"); 52 | f.write("PLATFORM=\n"); 53 | String plat = md.getPlat(); 54 | if (!plat.isEmpty()) { 55 | f.write("ifeq" + " ($(SPEC)," + arg.getSpec() + ")\n\tPLATFORM=" + plat + "\nendif\n\n"); 56 | } 57 | System.out.println("Generated " + utilsMk + "\n"); 58 | } catch (IOException e) { 59 | e.printStackTrace(); 60 | System.exit(1); 61 | } 62 | } 63 | 64 | private void generateRerun() { 65 | try (Writer f = Utility.getWriterObject(jInfo.getJDKVersion(), arg.getSpec(), rerunMk)) { 66 | f.write(Constants.HEADERCOMMENTS); 67 | String ignoreOnRerunStr = String.join(",", ignoreOnRerunList); 68 | f.write("IGNORE_ON_RERUN="); 69 | if (ignoreOnRerunList != null && !ignoreOnRerunList.isEmpty()) { 70 | f.write(ignoreOnRerunStr); 71 | } 72 | System.out.println("Generated " + rerunMk + "\n"); 73 | } catch (IOException e) { 74 | e.printStackTrace(); 75 | System.exit(1); 76 | } 77 | } 78 | 79 | public void clean() { 80 | File f = new File(utilsMk); 81 | f.delete(); 82 | f = new File(rerunMk); 83 | f.delete(); 84 | } 85 | } -------------------------------------------------------------------------------- /src/org/testKitGen/Variation.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | *******************************************************************************/ 14 | 15 | package org.testKitGen; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class Variation { 21 | enum PrintStatus { 22 | PRINT_CMD, PRINT_DISABLED, DO_NOT_PRINT; 23 | } 24 | private String variation; 25 | private String subTestName; 26 | private String mode; 27 | private String jvmOptions; 28 | private boolean isValid; 29 | private List disabledReasons; 30 | private PrintStatus status; 31 | private String prefix; 32 | 33 | public Variation(String subTestName, String variation) { 34 | this.subTestName = subTestName; 35 | this.variation = variation; 36 | this.isValid = true; 37 | this.jvmOptions = ""; 38 | this.disabledReasons = new ArrayList(); 39 | this.status = PrintStatus.DO_NOT_PRINT; 40 | this.prefix = ""; 41 | } 42 | 43 | public String getVariation() { 44 | return this.variation; 45 | } 46 | 47 | public String getSubTestName() { 48 | return this.subTestName; 49 | } 50 | 51 | public String getMode() { 52 | return this.mode; 53 | } 54 | 55 | public void setMode(String mode) { 56 | this.mode = mode; 57 | } 58 | 59 | public String getJvmOptions() { 60 | return this.jvmOptions; 61 | } 62 | 63 | public void setJvmOptions(String jvmOptions) { 64 | this.jvmOptions = jvmOptions; 65 | } 66 | 67 | public boolean isValid() { 68 | return this.isValid; 69 | } 70 | 71 | public void setValid(boolean isValid) { 72 | this.isValid = isValid; 73 | } 74 | 75 | public List getDisabledReasons() { 76 | return this.disabledReasons; 77 | } 78 | 79 | public void addDisabledReasons(String disabledReasons) { 80 | this.disabledReasons.add(disabledReasons); 81 | } 82 | 83 | public boolean isDisabled() { 84 | return getDisabledReasons().size() != 0; 85 | } 86 | 87 | public void setStatus(PrintStatus status) { 88 | this.status = status; 89 | } 90 | 91 | public PrintStatus getStatus() { 92 | return status; 93 | } 94 | 95 | public void setPrefix(String prefix) { 96 | this.prefix = prefix; 97 | } 98 | 99 | public String getPrefix() { 100 | return prefix; 101 | } 102 | } -------------------------------------------------------------------------------- /testEnv.mk: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # https://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | ############################################################################## 14 | 15 | _TESTTARGET = $(firstword $(MAKECMDGOALS)) 16 | TESTTARGET = $(patsubst _%,%,$(_TESTTARGET)) 17 | 18 | testEnvSetup: 19 | 20 | testEnvTeardown: 21 | 22 | 23 | ifneq (,$(findstring JITAAS,$(TEST_FLAG))) 24 | testEnvSetup: 25 | $(TEST_JDK_HOME)/bin/jitserver & 26 | 27 | testEnvTeardown: 28 | pkill -9 -xf "$(TEST_JDK_HOME)/bin/jitserver"; true 29 | 30 | RESERVED_OPTIONS += -XX:+UseJITServer 31 | endif 32 | 33 | ifneq (,$(findstring dev.external,$(TESTTARGET))) 34 | testEnvSetup: 35 | sudo podman system prune --all --force 36 | 37 | testEnvTeardown: 38 | sudo podman system prune --all --force 39 | 40 | endif 41 | 42 | export TR_silentEnv=1 43 | export TR_enableBreakOnDFSet=1 44 | --------------------------------------------------------------------------------