blob: db42d25c94d8bb3aa1335915ca2f8660a6f56e5e [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) {
Colin Cross323dc602020-09-18 14:25:31 -070023 t.Parallel()
Paul Duffin1c6c1c72020-02-21 10:28:43 +000024 ctx := testCc(t, `
25 cc_library_headers {
26 name: "headers",
27 export_include_dirs: ["my_include"],
28 }
29 cc_library_static {
30 name: "lib",
31 srcs: ["foo.c"],
32 header_libs: ["headers"],
33 }
34 `)
35
36 // test if header search paths are correctly added
37 cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
38 cflags := cc.Args["cFlags"]
39 if !strings.Contains(cflags, " -Imy_include ") {
40 t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
41 }
42}
Paul Duffinf5ea9e12020-02-21 10:57:00 +000043
44func TestPrebuiltLibraryHeaders(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070045 t.Parallel()
Paul Duffinf5ea9e12020-02-21 10:57:00 +000046 ctx := testCc(t, `
47 cc_prebuilt_library_headers {
48 name: "headers",
49 export_include_dirs: ["my_include"],
50 }
51 cc_library_static {
52 name: "lib",
53 srcs: ["foo.c"],
54 header_libs: ["headers"],
55 }
56 `)
57
58 // test if header search paths are correctly added
59 cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
60 cflags := cc.Args["cFlags"]
61 if !strings.Contains(cflags, " -Imy_include ") {
62 t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
63 }
64}