11285115cSWilliam A. Kennington III# Copyright 2021 Google LLC 21285115cSWilliam A. Kennington III# 31285115cSWilliam A. Kennington III# Licensed under the Apache License, Version 2.0 (the "License"); 41285115cSWilliam A. Kennington III# you may not use this file except in compliance with the License. 51285115cSWilliam A. Kennington III# You may obtain a copy of the License at 61285115cSWilliam A. Kennington III# 71285115cSWilliam A. Kennington III# http://www.apache.org/licenses/LICENSE-2.0 81285115cSWilliam A. Kennington III# 91285115cSWilliam A. Kennington III# Unless required by applicable law or agreed to in writing, software 101285115cSWilliam A. Kennington III# distributed under the License is distributed on an "AS IS" BASIS, 111285115cSWilliam A. Kennington III# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121285115cSWilliam A. Kennington III# See the License for the specific language governing permissions and 131285115cSWilliam A. Kennington III# limitations under the License. 141285115cSWilliam A. Kennington III 151285115cSWilliam A. Kennington IIIgtest = dependency('gtest', main: true, disabler: true, required: false) 161285115cSWilliam A. Kennington IIIgmock = dependency('gmock', disabler: true, required: false) 171285115cSWilliam A. Kennington IIIif not gtest.found() or not gmock.found() 181285115cSWilliam A. Kennington III gtest_proj = import('cmake').subproject( 191285115cSWilliam A. Kennington III 'googletest', 201285115cSWilliam A. Kennington III cmake_options: [ 211285115cSWilliam A. Kennington III '-DCMAKE_CXX_FLAGS=-Wno-pedantic', 221285115cSWilliam A. Kennington III ], 231285115cSWilliam A. Kennington III required: false) 241285115cSWilliam A. Kennington III if gtest_proj.found() 251285115cSWilliam A. Kennington III gtest = declare_dependency( 261285115cSWilliam A. Kennington III dependencies: [ 271285115cSWilliam A. Kennington III dependency('threads'), 281285115cSWilliam A. Kennington III gtest_proj.dependency('gtest'), 291285115cSWilliam A. Kennington III gtest_proj.dependency('gtest_main'), 301285115cSWilliam A. Kennington III ]) 311285115cSWilliam A. Kennington III gmock = gtest_proj.dependency('gmock') 321285115cSWilliam A. Kennington III else 33*47a0ada2SPatrick Williams assert(not build_tests.allowed(), 'Googletest is required') 341285115cSWilliam A. Kennington III endif 351285115cSWilliam A. Kennington IIIendif 361285115cSWilliam A. Kennington III 371285115cSWilliam A. Kennington IIItests = [ 381285115cSWilliam A. Kennington III 'iface_test', 391285115cSWilliam A. Kennington III 'sock_test', 401285115cSWilliam A. Kennington III #'ncsi_test', # TODO: Re-enable when fixed 411285115cSWilliam A. Kennington III] 421285115cSWilliam A. Kennington III 431285115cSWilliam A. Kennington IIIncsid_test_headers = include_directories('.') 441285115cSWilliam A. Kennington III 451285115cSWilliam A. Kennington IIIncsid_test_lib = static_library( 461285115cSWilliam A. Kennington III 'ncsid_test', 471285115cSWilliam A. Kennington III [ 481285115cSWilliam A. Kennington III 'net_iface_mock.cpp', 491285115cSWilliam A. Kennington III 'nic_mock.cpp', 501285115cSWilliam A. Kennington III ], 511285115cSWilliam A. Kennington III include_directories: ncsid_test_headers, 521285115cSWilliam A. Kennington III implicit_include_directories: false, 531285115cSWilliam A. Kennington III dependencies: ncsid) 541285115cSWilliam A. Kennington III 551285115cSWilliam A. Kennington IIIncsid_test = declare_dependency( 561285115cSWilliam A. Kennington III dependencies: ncsid, 571285115cSWilliam A. Kennington III include_directories: ncsid_test_headers, 581285115cSWilliam A. Kennington III link_with: ncsid_test_lib) 591285115cSWilliam A. Kennington III 601285115cSWilliam A. Kennington IIIforeach t : tests 611285115cSWilliam A. Kennington III test(t, executable(t.underscorify(), t + '.cpp', 621285115cSWilliam A. Kennington III implicit_include_directories: false, 631285115cSWilliam A. Kennington III dependencies: [gtest, gmock, ncsid_test])) 641285115cSWilliam A. Kennington IIIendforeach 651285115cSWilliam A. Kennington III 661285115cSWilliam A. Kennington IIIscript_tests = [ 671285115cSWilliam A. Kennington III 'normalize_ip_test', 681285115cSWilliam A. Kennington III 'normalize_mac_test', 691285115cSWilliam A. Kennington III] 701285115cSWilliam A. Kennington III 711285115cSWilliam A. Kennington IIIscript_env = environment() 721285115cSWilliam A. Kennington IIIscript_deps = [] 731285115cSWilliam A. Kennington IIIscript_env.set('NORMALIZE_IP', normalize_ip.full_path()) 741285115cSWilliam A. Kennington IIIscript_deps += normalize_ip 751285115cSWilliam A. Kennington IIIscript_env.set('NORMALIZE_MAC', normalize_mac.full_path()) 761285115cSWilliam A. Kennington IIIscript_deps += normalize_mac 771285115cSWilliam A. Kennington III 781285115cSWilliam A. Kennington IIIforeach st : script_tests 791285115cSWilliam A. Kennington III test(st, find_program('bash'), args: files(st + '.sh'), 801285115cSWilliam A. Kennington III protocol: 'tap', env: script_env, depends: script_deps) 811285115cSWilliam A. Kennington IIIendforeach 82