• 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    if (defined(invoker.ldflags)) {
22      print(invoker.ldflags)
23    }
24    if (defined(invoker.cflags)) {
25      print(invoker.cflags)
26      cflags += invoker.cflags
27    }
28  }
29}
30
31template("ohos_fuzztest") {
32  executable(target_name) {
33    forward_variables_from(invoker, "*")
34    testonly = true
35    deps = []
36    if (defined(invoker.deps)) {
37      deps += invoker.deps
38    }
39    if (defined(invoker.cflags)) {
40      cflags += invoker.cflags
41    }
42    ldflags += [ "-fsanitize=fuzzer" ]
43    cflags += [
44      "-fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters",
45      "-fsanitize=fuzzer",
46    ]
47  }
48}
49