• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 Huawei Device Co., Ltd.
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.
14template("ohos_unittest") {
15  if (defined(invoker.ldflags)) {
16    print(invoker.ldflags)
17  }
18  executable(target_name) {
19    forward_variables_from(invoker, "*")
20    testonly = true
21
22    if (defined(invoker.deps)) {
23      deps += invoker.deps
24    }
25
26    if (defined(invoker.public_deps)) {
27      public_deps += invoker.public_deps
28    }
29    if (defined(invoker.ldflags)) {
30      print(invoker.ldflags)
31    }
32    if (defined(invoker.cflags)) {
33      print(invoker.cflags)
34      cflags += invoker.cflags
35    }
36  }
37}
38
39template("ohos_fuzztest") {
40  executable(target_name) {
41    forward_variables_from(invoker, "*")
42    testonly = true
43    deps = []
44    if (defined(invoker.deps)) {
45      deps += invoker.deps
46    }
47    if (defined(invoker.cflags)) {
48      cflags += invoker.cflags
49    }
50    ldflags += [ "-fsanitize=fuzzer" ]
51    cflags += [
52      "-fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters",
53      "-fsanitize=fuzzer",
54    ]
55  }
56}
57