summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/tools/clang/plugins/tests/test.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/libwebrtc/tools/clang/plugins/tests/test.sh
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/tools/clang/plugins/tests/test.sh')
-rwxr-xr-xthird_party/libwebrtc/tools/clang/plugins/tests/test.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/third_party/libwebrtc/tools/clang/plugins/tests/test.sh b/third_party/libwebrtc/tools/clang/plugins/tests/test.sh
new file mode 100755
index 0000000000..262ebbba29
--- /dev/null
+++ b/third_party/libwebrtc/tools/clang/plugins/tests/test.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Hacky, primitive testing: This runs the style plugin for a set of input files
+# and compares the output with golden result files.
+
+E_BADARGS=65
+E_FAILEDTEST=1
+
+failed_any_test=
+
+# Prints usage information.
+usage() {
+ echo "Usage: $(basename "${0}")" \
+ "<Path to the llvm build dir, usually Release+Asserts>"
+ echo ""
+ echo " Runs all the libFindBadConstructs unit tests"
+ echo ""
+}
+
+# Runs a single test case.
+do_testcase() {
+ local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
+ -Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \
+ -Xclang -plugin -Xclang find-bad-constructs ${1} 2>&1)"
+ local diffout="$(echo "${output}" | diff - "${2}")"
+ if [ "${diffout}" = "" ]; then
+ echo "PASS: ${1}"
+ else
+ failed_any_test=yes
+ echo "FAIL: ${1}"
+ echo "Output of compiler:"
+ echo "${output}"
+ echo "Expected output:"
+ cat "${2}"
+ echo
+ fi
+}
+
+# Validate input to the script.
+if [[ -z "${1}" ]]; then
+ usage
+ exit ${E_BADARGS}
+elif [[ ! -d "${1}" ]]; then
+ echo "${1} is not a directory."
+ usage
+ exit ${E_BADARGS}
+else
+ export CLANG_DIR="${PWD}/${1}"
+ echo "Using clang directory ${CLANG_DIR}..."
+
+ # The golden files assume that the cwd is this directory. To make the script
+ # work no matter what the cwd is, explicitly cd to there.
+ cd "$(dirname "${0}")"
+
+ if [ "$(uname -s)" = "Linux" ]; then
+ export LIB=so
+ elif [ "$(uname -s)" = "Darwin" ]; then
+ export LIB=dylib
+ fi
+fi
+
+for input in *.cpp; do
+ do_testcase "${input}" "${input%cpp}txt"
+done
+
+if [[ "${failed_any_test}" ]]; then
+ exit ${E_FAILEDTEST}
+fi