blob: 564ef61fb59d724d3364874dca531e664f113624 [file] [log] [blame]
Paul Duffin1c6c1c72020-02-21 10:28:43 +00001// Copyright 2020 Google Inc. 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 cc
16
17import (
18 "strings"
19 "testing"
20)
21
22func TestLibraryHeaders(t *testing.T) {
23 ctx := testCc(t, `
24 cc_library_headers {
25 name: "headers",
26 export_include_dirs: ["my_include"],
27 }
28 cc_library_static {
29 name: "lib",
30 srcs: ["foo.c"],
31 header_libs: ["headers"],
32 }
33 `)
34
35 // test if header search paths are correctly added
36 cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
37 cflags := cc.Args["cFlags"]
38 if !strings.Contains(cflags, " -Imy_include ") {
39 t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
40 }
41}
Paul Duffinf5ea9e12020-02-21 10:57:00 +000042
43func TestPrebuiltLibraryHeaders(t *testing.T) {
44 ctx := testCc(t, `
45 cc_prebuilt_library_headers {
46 name: "headers",
47 export_include_dirs: ["my_include"],
48 }
49 cc_library_static {
50 name: "lib",
51 srcs: ["foo.c"],
52 header_libs: ["headers"],
53 }
54 `)
55
56 // test if header search paths are correctly added
57 cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
58 cflags := cc.Args["cFlags"]
59 if !strings.Contains(cflags, " -Imy_include ") {
60 t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
61 }
62}