Skip to content

Commit

Permalink
Script and doc changes based on Windows testing (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulthomson committed Dec 19, 2018
1 parent 699e819 commit f0383de
Show file tree
Hide file tree
Showing 45 changed files with 530 additions and 85 deletions.
17 changes: 9 additions & 8 deletions build/travis/1-install-deps-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GITHUB_RELEASE_TOOL_VERSION="v1.1.0"

if [ "$(uname)" == "Darwin" ];
then
brew install python3 unzip wget
brew install python3 unzip
GITHUB_RELEASE_TOOL_ARCH="darwin_amd64"
ANDROID_HOST_PLATFORM="darwin"
fi
Expand All @@ -35,19 +35,20 @@ if [ "$(uname)" == "Linux" ];
then
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get update -q
sudo apt-get install python3.6 unzip wget -y
sudo apt-get install python3.6 unzip -y
GITHUB_RELEASE_TOOL_ARCH="linux_amd64"
ANDROID_HOST_PLATFORM="linux"
fi


pushd /data/bin
wget "https://github.com/${GITHUB_RELEASE_TOOL_USER}/github-release/releases/download/${GITHUB_RELEASE_TOOL_VERSION}/github-release_${GITHUB_RELEASE_TOOL_VERSION}_${GITHUB_RELEASE_TOOL_ARCH}.tar.gz"
curl -Lo "github-release_${GITHUB_RELEASE_TOOL_VERSION}_${GITHUB_RELEASE_TOOL_ARCH}.tar.gz" \
"https://github.com/${GITHUB_RELEASE_TOOL_USER}/github-release/releases/download/${GITHUB_RELEASE_TOOL_VERSION}/github-release_${GITHUB_RELEASE_TOOL_VERSION}_${GITHUB_RELEASE_TOOL_ARCH}.tar.gz"
tar xf "github-release_${GITHUB_RELEASE_TOOL_VERSION}_${GITHUB_RELEASE_TOOL_ARCH}.tar.gz"
popd


# Android SDK (ANDROID_HOST_PLATFORM must be set to linux, darwin, or windows).
# Android SDK (ANDROID_HOST_PLATFORM must be set to linux, darwin, or windows, and ANDROID_HOME must be set to some directory).

ANDROID_TOOLS_FILENAME="sdk-tools-${ANDROID_HOST_PLATFORM}-4333796.zip"
ANDROID_NDK_FILENAME="android-ndk-r18b-${ANDROID_HOST_PLATFORM}-x86_64.zip"
Expand All @@ -57,23 +58,23 @@ mkdir -p "${ANDROID_HOME}"
pushd "${ANDROID_HOME}"

# Android: "sdk-tools.zip" "tools":
wget -q "http://dl.google.com/android/repository/${ANDROID_TOOLS_FILENAME}"
curl -qo "${ANDROID_TOOLS_FILENAME}" "http://dl.google.com/android/repository/${ANDROID_TOOLS_FILENAME}"
unzip -q "${ANDROID_TOOLS_FILENAME}"
rm "${ANDROID_TOOLS_FILENAME}"

# Android "android-ndk.zip" "ndk-bundle"
wget -q "https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}"
curl -qo "${ANDROID_NDK_FILENAME}" "https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}"
unzip -q "${ANDROID_NDK_FILENAME}"
rm "${ANDROID_NDK_FILENAME}"
mv android-ndk-*/ ndk-bundle

# Android "platform-tools.zip" "platform-tools"
wget -q "https://dl.google.com/android/repository/${ANDROID_PLATFORM_TOOLS_FILENAME}"
curl -qo "${ANDROID_PLATFORM_TOOLS_FILENAME}" "https://dl.google.com/android/repository/${ANDROID_PLATFORM_TOOLS_FILENAME}"
unzip -q "${ANDROID_PLATFORM_TOOLS_FILENAME}"
rm "${ANDROID_PLATFORM_TOOLS_FILENAME}"

# Android "platforms" and "build-tools"
echo y | sdkmanager \
echo y | tools/bin/sdkmanager \
"platforms;android-26" \
"build-tools;28.0.2"

Expand Down
2 changes: 1 addition & 1 deletion build/travis/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2018 The GraphicsFuzz Project Authors
#
Expand Down
4 changes: 3 additions & 1 deletion build/travis/check_headers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2018 The GraphicsFuzz Project Authors
#
Expand Down Expand Up @@ -33,6 +33,8 @@ def exclude_dirname(f: str):
"__pycache__",
".externalNativeBuild",
".mvn",
"cmake-build-debug",
"cmake-build-release",

]

Expand Down
2 changes: 1 addition & 1 deletion build/travis/licenses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2018 The GraphicsFuzz Project Authors
#
Expand Down
2 changes: 1 addition & 1 deletion build/travis/release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2018 The GraphicsFuzz Project Authors
#
Expand Down
6 changes: 4 additions & 2 deletions docs/android-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ by following our
[continuous integration script](../build/travis/1-install-deps-travis.sh);
the download of the Android SDK starts about halfway down.
You may need to set some environment variables as specified in the comments.
On Windows, you can use the Git Bash shell.

Ensure that the `ANDROID_HOME=/path/to/android-sdk` and `ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle` environment variables are set;
you may need to open IntelliJ IDEA from the terminal depending on how
Ensure that the `ANDROID_HOME=/path/to/android-sdk` and `ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle` environment variables are set.
If using IntelliJ and/or Android Studio,
you may need to open your IDE from the terminal depending on how
you set the environment variables.

You should also add the `android-sdk/platform-tools` directory
Expand Down
5 changes: 4 additions & 1 deletion docs/glsl-fuzz-develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ page](glsl-fuzz-releases.md).
* [Maven](https://maven.apache.org/)
* [Python 3.5+](https://www.python.org/)

* For our Android workers: [Android SDK & NDK](https://developer.android.com/studio/#command-tools)
* For our Android workers: [Android SDK & NDK](android-notes.md)
* For the Vulkan desktop worker: [Vulkan SDK](https://vulkan.lunarg.com/sdk/home)

> Our *workers* are applications that run on the device you wish to test;
Expand Down Expand Up @@ -89,6 +89,9 @@ or read the [walkthrough for a brief overview of using all tools

#### Android

Ensure that the `ANDROID_HOME=/path/to/android-sdk` and
`ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle` environment variables are set.

```shell
cd vulkan-worker
./gradlew assembleDebug
Expand Down
2 changes: 1 addition & 1 deletion docs/glsl-fuzz-generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ glsl-generate --seed 0 samples/donors samples/100 10 "100" family_100 work/shade
# Generate some "Vulkan-compatible" GLSL version 300 es shaders that can be translated to SPIR-V for Vulkan testing.
glsl-generate --seed 0 --generate_uniform_bindings --max_uniforms 10 samples/donors samples/310es 10 "310 es" family_vulkan work/shaderfamilies

# The lines above will take approx. 1-2 minutes each, and will generate a shader family for every
# Each line above will take approx. 1 minute, and will generate a shader family for every
# shader in samples/300es or samples/100:
ls work/shaderfamilies

Expand Down
16 changes: 13 additions & 3 deletions docs/glsl-fuzz-walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ glsl-fuzz is a testing framework for automatically finding and simplifying bugs
by generating, running, and reducing GLSL shaders.

In this walkthrough, we will briefly demonstrate most features of glsl-fuzz from start to finish, including our browser-based UI.
We present commands assuming a Linux/Mac environment,
but Windows users can adapt the commands or
use the Git Bash shell.

The use of `glsl-fuzz` can be roughly split into the following steps:

Expand Down Expand Up @@ -68,6 +71,11 @@ You will need to install Python 3.5 or higher, either:
* By downloading from [https://www.python.org/downloads/](https://www.python.org/downloads/).
* By downloading and installing some other Python 3 distribution.

For Windows: most recent installers of Python
add `py`, a Python launcher, to your path.
Our scripts attempt to use `py -3 SCRIPT.py` to
execute `SCRIPT.py` using Python 3.5+.

### `adb`

The Vulkan worker for Android requires that `adb` is on your path.
Expand Down Expand Up @@ -164,7 +172,7 @@ glsl-generate --seed 0 samples/100 samples/donors 10 "100" family_100 work/shade
# Generate some "Vulkan-compatible" GLSL version 300 es shaders that can be translated to SPIR-V for Vulkan testing.
glsl-generate --seed 0 --generate-uniform-bindings --max-uniforms 10 samples/310es samples/donors 10 "310 es" family_vulkan work/shaderfamilies

# The lines above will take approx. 1-2 minutes each, and will generate a shader family for every
# Each line above will take approx. 1 minute, and will generate a shader family for every
# shader in samples/300es or samples/100:
ls work/shaderfamilies

Expand Down Expand Up @@ -388,8 +396,10 @@ the `vulkan-worker-android` app running on the Android device.
> re-run SPIR-V shaders on the device.
> [We describe this in more detail below](#running-shaders-from-the-command-line).
The intermediate files are saved to the current directory.
For example:
The intermediate files are saved in the current directory under
a `WORKERNAME/` directory.
For example, we might have a worker name of `pixel3`
and so under `pixel3/` we will see:

```
test.vert # The default GLSL vertex shader.
Expand Down
42 changes: 33 additions & 9 deletions docs/glsl-reduce-walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ glsl-reduce is a tool for automatically reducing a GLSL shader with respect to a
In this walkthrough, we will use a mock shader compiler bug to demonstrate how
to use glsl-reduce in action.

## Requirements

**Summary:** the latest release zip, Java 8+, and Python 3.5+.

### Release zip

We will be using the latest release zip `graphicsfuzz-1.0.zip`.
You can download this from the [releases page](glsl-fuzz-releases.md)
or [build it from source](glsl-fuzz-build.md).
or [build it from source](glsl-fuzz-develop.md).

Add the following directories to your path:

Expand All @@ -17,13 +23,15 @@ Add the following directories to your path:
* `graphicsfuzz-1.0/bin/Mac`
* `graphicsfuzz-1.0/bin/Windows`

The `graphicsfuzz-1.0/` directory is the unzipped graphicsfuzz release.
The `graphicsfuzz-1.0/` directory is the unzipped release.
If building from source, this directory can be found at `graphicsfuzz/target/graphicsfuzz-1.0/`.

### Java 8+

You will also need to install the latest version of the Java 8 Development Kit,
either:

* From your system's package manager. E.g. `sudo apt-get install openjdk-8-jdk`.
* From your system's package manager. E.g. Ubuntu: `sudo apt-get install openjdk-8-jdk`.
* By [downloading and installing Oracle's binary distribution](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (look for Java SE 8uXXX then the JDK link).
* By downloading and installing some other OpenJDK binary distribution for your platform.

Expand All @@ -34,16 +42,32 @@ java -version
# Output: openjdk version "1.8.0_181"
```

### Python 3.5+

You will need to install Python 3.5 or higher, either:

* From your system's package manager. E.g. Ubuntu: `sudo apt-get install python3`.
* By downloading from [https://www.python.org/downloads/](https://www.python.org/downloads/).
* By downloading and installing some other Python 3 distribution.

For Windows: most recent installers of Python
add `py`, a Python launcher, to your path.
Our scripts attempt to use `py -3 SCRIPT.py` to
execute `SCRIPT.py` using Python 3.5+.


## glsl-reduce in action

We'll start by illustrating a mock shader compiler bug. We present commands assuming a Linux/Mac environment, but they should be easy to adapt to a Windows setting.
We'll start by illustrating a mock shader compiler bug. We present commands assuming a Linux/Mac environment,
but Windows users can adapt the commands or
use the Git Bash shell.

```sh
# Copy the sample shaders into the current directory:
# Copy the sample files into the current directory:
cp -r graphicsfuzz-1.0/examples/glsl-reduce-walkthrough .

# Run the fake shader compiler on the fragment shader file:
python glsl-reduce-walkthrough/fake_compiler.py glsl-reduce-walkthrough/colorgrid_modulo.frag
glsl-reduce-walkthrough/fake_compiler glsl-reduce-walkthrough/colorgrid_modulo.frag

# Output:
# Fatal error: too much indexing.
Expand All @@ -53,7 +77,7 @@ python glsl-reduce-walkthrough/fake_compiler.py glsl-reduce-walkthrough/colorgri
Our fake compiler fails to compile the valid shader because it cannot handle shaders
with a lot of indexing. Thus, we have found a compiler bug.

> Take a look at `fake_compiler.py` if you want to see why the fake compiler generates this error
> Take a look at `glsl-reduce-walkthrough/fake_compiler.py` if you want to see why the fake compiler generates this error
> message for the shader. This is not important for understanding how to use the reducer.
Let's now use glsl-reduce to get a much smaller shader that causes the compiler to fail with this error:
Expand All @@ -72,7 +96,7 @@ glsl-reduce glsl-reduce-walkthrough/colorgrid_modulo.json ./glsl-reduce-walkthro
# <lots of messages about the reducer's progress>

# Confirm that the reduced fragment shader file still reproduces the issue
python glsl-reduce-walkthrough/fake_compiler.py reduction_results/colorgrid_modulo_reduced_final.frag
glsl-reduce-walkthrough/fake_compiler reduction_results/colorgrid_modulo_reduced_final.frag

# Output:
# Fatal error: too much indexing.
Expand Down Expand Up @@ -131,7 +155,7 @@ cat slipped_reduction_results/colorgrid_modulo_reduced_final.frag
# <a shader with an empty main>

# Does it still give us the fatal error?
python glsl-reduce-walkthrough/fake_compiler.py reduction_results/colorgrid_modulo_reduced_final.frag
glsl-reduce-walkthrough/fake_compiler slipped_reduction_results/colorgrid_modulo_reduced_final.frag

# Output:
# Internal error: something went wrong inlining 'floor'.
Expand Down
2 changes: 1 addition & 1 deletion envbuild.py.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2018 The GraphicsFuzz Project Authors
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright 2018 The GraphicsFuzz Project Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if type -P python3 >/dev/null; then
python3 ${BASH_SOURCE}.py "$@"
elif type -P py >/dev/null; then
py -3 ${BASH_SOURCE}.py "$@"
else
python ${BASH_SOURCE}.py "$@"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@echo off

@REM
@REM Copyright 2018 The GraphicsFuzz Project Authors
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@REM See the License for the specific language governing permissions and
@REM limitations under the License.
@REM

where /q py
IF ERRORLEVEL 0 (
py -3 "%~dpn0.py" %*
) ELSE (
where /q python3
IF ERRORLEVEL 0 (
python3 "%~dpn0.py" %*
) ELSE (
python "%~dpn0.py" %*
)
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

# Copyright 2018 The GraphicsFuzz Project Authors
#
Expand All @@ -18,26 +18,27 @@
import sys

if len(sys.argv) != 2:
sys.stderr.write("Usage: " + sys.argv[0] + " <shader>\n")
exit(1)
sys.stderr.write("Usage: " + sys.argv[0] + " <shader>\n")
exit(1)

filename = sys.argv[1]

if not os.path.isfile(filename):
sys.stderr.write("Input file " + filename + " does not exist.\n")
exit(1)
sys.stderr.write("Input file " + filename + " does not exist.\n")
exit(1)

text = open(filename, "r").read()
with open(filename, "r") as f:
text = f.read()

# Pretend that an internal error occurred if the file doesn't contain 'floor'.
if (not "floor" in text):
sys.stderr.write("Internal error: something went wrong inlining 'floor'.\n")
exit(2)
if "floor" not in text:
sys.stderr.write("Internal error: something went wrong inlining 'floor'.\n")
exit(2)

# Pretend that a fatal error occurred if the file contains '[i]' at least twice.
if (text.count("[i]") > 1):
sys.stderr.write("Fatal error: too much indexing.\n")
exit(2)
if text.count("[i]") > 1:
sys.stderr.write("Fatal error: too much indexing.\n")
exit(2)

# Pretend that compilation succeeded.
sys.stdout.write("Compilation succeeded [not really!]\n")
Expand Down
Loading

0 comments on commit f0383de

Please sign in to comment.