blob: 58e98f68e32e164ac05cf47061d037c9ac9262f3 [file] [log] [blame]
Sasha Smundak1471eb22021-03-10 12:10:29 -08001// Copyright 2021 Google LLC
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 mk2rbc
16
17import (
18 "fmt"
19 "path/filepath"
20 "reflect"
21 "testing"
22)
23
24type dirResolverForTest struct {
25 ScopeBase
26}
27
28func (t dirResolverForTest) Get(name string) string {
29 if name != "BUILD_SYSTEM" {
30 return fmt.Sprintf("$(%s)", name)
31 }
32 return getTestDirectory()
33}
34
35func TestSoongVariables(t *testing.T) {
36 testFile := filepath.Join(getTestDirectory(), "soong_variables.mk.test")
37 var actual testVariables
38 if err := FindSoongVariables(testFile, dirResolverForTest{}, &actual); err != nil {
39 t.Fatal(err)
40 }
41 expected := testVariables{[]testVar{
42 {"BUILD_ID", VarClassSoong, starlarkTypeString},
43 {"PLATFORM_SDK_VERSION", VarClassSoong, starlarkTypeInt},
44 {"DEVICE_PACKAGE_OVERLAYS", VarClassSoong, starlarkTypeList},
Cole Faustc85d08f2023-05-09 15:00:58 -070045 {"ENABLE_CFI", VarClassSoong, starlarkTypeString},
46 {"ENABLE_PREOPT", VarClassSoong, starlarkTypeString},
Sasha Smundak1471eb22021-03-10 12:10:29 -080047 }}
48 if !reflect.DeepEqual(expected, actual) {
49 t.Errorf("\nExpected: %v\n Actual: %v", expected, actual)
50 }
51}