xref: /aosp_15_r20/external/swiftshader/tests/regres/llvm/llvm_test.go (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
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//    http://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
15package llvm_test
16
17import (
18	"flag"
19	"os"
20	"testing"
21
22	"swiftshader.googlesource.com/SwiftShader/tests/regres/llvm"
23)
24
25var testLLVMDownloads = flag.Bool("test-llvm-downloads", false, "include download tests of llvm")
26
27func TestMain(m *testing.M) {
28	flag.Parse()
29	os.Exit(m.Run())
30}
31
32func TestLLVMDownloads(t *testing.T) {
33	if !*testLLVMDownloads {
34		t.Skip("LLVM download tests disabled. Enable with --test-llvm-downloads")
35	}
36	for _, version := range []llvm.Version{
37		{Major: 10, Minor: 0, Point: 0},
38	} {
39		t.Logf("Downloading %v...", version)
40		for _, os := range []string{"linux", "darwin", "windows"} {
41			data, err := version.DownloadForOS(os)
42			switch {
43			case err != nil:
44				t.Errorf("Download of LLVM %v failed with: %v", version, err)
45			case len(data) == 0:
46				t.Errorf("Download of LLVM %v resulted in no data", version)
47			default:
48				t.Logf("done\n")
49			}
50		}
51	}
52}
53