Paul Duffin | 1c6c1c7 | 2020-02-21 10:28:43 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "strings" |
| 19 | "testing" |
| 20 | ) |
| 21 | |
| 22 | func 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 Duffin | f5ea9e1 | 2020-02-21 10:57:00 +0000 | [diff] [blame] | 42 | |
| 43 | func 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 | } |