blob: 51fbc15e119b7d44ba3102ecb5bc641559411f8b [file] [log] [blame]
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -08001// Copyright 2018 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 bpf
16
17import (
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080018 "os"
19 "testing"
20
21 "android/soong/android"
Colin Cross815daf92019-05-14 16:05:20 -070022 "android/soong/cc"
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080023)
24
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080025func TestMain(m *testing.M) {
Paul Duffin854d6612021-03-16 13:36:55 +000026 os.Exit(m.Run())
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080027}
28
Paul Duffin89648f92021-03-20 00:36:55 +000029var prepareForBpfTest = android.GroupFixturePreparers(
Paul Duffin12c7eb82021-02-24 18:51:54 +000030 cc.PrepareForTestWithCcDefaultModules,
31 android.FixtureMergeMockFs(
32 map[string][]byte{
33 "bpf.c": nil,
34 "BpfTest.cpp": nil,
35 },
36 ),
37 PrepareForTestWithBpf,
38)
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080039
40func TestBpfDataDependency(t *testing.T) {
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080041 bp := `
42 bpf {
43 name: "bpf.o",
44 srcs: ["bpf.c"],
45 }
46
47 cc_test {
48 name: "vts_test_binary_bpf_module",
49 srcs: ["BpfTest.cpp"],
50 data: [":bpf.o"],
Colin Cross815daf92019-05-14 16:05:20 -070051 gtest: false,
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080052 }
53 `
54
Paul Duffin89648f92021-03-20 00:36:55 +000055 prepareForBpfTest.RunTestWithBp(t, bp)
Jaewoong Jung5f3fb4b2018-12-13 15:01:46 -080056
57 // We only verify the above BP configuration is processed successfully since the data property
58 // value is not available for testing from this package.
59 // TODO(jungjw): Add a check for data or move this test to the cc package.
60}