# Copyright (c) 2009 XORP, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, Version 2, June
# 1991 as published by the Free Software Foundation. Redistribution
# and/or modification of this program under the terms of any other
# version of the GNU General Public License is not permitted.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
# see the GNU General Public License, Version 2, a copy of which can be
# found in the XORP LICENSE.gpl file.
#
# XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
# http://xorp.net

# $XORP$

import os
Import("env")

env = env.Clone()

env.AppendUnique(CPPPATH = [
	'#',
	'$BUILDDIR',
	'$BUILDDIR/rib',
	'$BUILDDIR/rib/tests',
	])

env.AppendUnique(LIBPATH = [
	'$BUILDDIR/rib',
	'$BUILDDIR/policy',
	'$BUILDDIR/policy/backend',
	'$BUILDDIR/policy/common',
	'$BUILDDIR/libfeaclient',
	'$BUILDDIR/xrl/interfaces',
	'$BUILDDIR/xrl/targets',
	'$BUILDDIR/libproto',
	'$BUILDDIR/libxipc',
	'$BUILDDIR/libxorp',
	'$BUILDDIR/libcomm',
	])

env.AppendUnique(LIBS = [
	'xorp_rib',
	#'xorp_rib_xrl', #notyet
	'xorp_fea_client',
	'xif_rib',
	'xif_fea_ifmgr_mirror',
	'xif_fea_ifmgr_replicator',
	'xif_fti',
	'xif_rib_client',
	'xif_finder_event_notifier',
	'xif_redist4',
	'xif_redist6',
	'xif_redist_transaction4',
	'xif_redist_transaction6',
	'xif_policy_redist4',
	'xif_policy_redist6',
	'xif_profile_client',
	'xst_fea_ifmgr_mirror',
	'xst_rib',
	'xorp_policy_backend',
	'xorp_policy_common',
	'xorp_proto',
	'xorp_finder',
	'xorp_ipc',
	'xorp_core',
	'xorp_comm',
	])

# XXX: Shell script wrappers here.
# These just take input from a file 'command'.
#test_rib_direct.cc
#test_rib_direct.sh
#test_rib_xrls.cc
#test_rib_xrls.sh

test_deletion = env.AutoTest(target = 'test_deletion',
                             source = [
                                 'test_deletion.cc',
                                 'rt_tab_expect.cc'
                             ])

test_redist = env.AutoTest(target = 'test_redist',
                           source = 'test_redist.cc')

test_register = env.AutoTest(target = 'test_register',
                             source = [
                                 'test_register.cc',
                                 'dummy_register_server.cc'
                             ])

test_direct = env.AutoTest(target = 'test_rib_direct',
                             source = [
                                 'test_rib_direct.cc',
                                 '../parser.cc',
                                 'dummy_register_server.cc'
                             ])

test_xrl = env.AutoTest(target = 'test_rib_xrls',
                             source = [
                                 'test_rib_xrls.cc',
                                 '../parser.cc',
                                 'dummy_register_server.cc'
                             ])

if env['enable_tests']:
    test_source_dir = os.path.join(env['xorp_sourcedir'], "rib")
    test_source_dir = os.path.join(test_source_dir, "tests")

    test_build_dir = os.path.join(env['builddir'], "rib")
    test_build_dir = os.path.join(test_build_dir, "tests")

    Execute(Copy(os.path.join(test_build_dir, "commands"),
               os.path.join(test_source_dir, "commands")))

    Execute(Copy(os.path.join(test_build_dir, "test_rib_direct.sh"),
               os.path.join(test_source_dir, "test_rib_direct.sh")))

    Execute(Copy(os.path.join(test_build_dir, "test_rib_xrls.sh"),
               os.path.join(test_source_dir, "test_rib_xrls.sh")))

    Default(test_deletion, test_redist, test_register, test_direct, test_xrl)

# XXX NOTYET: part of compound test, scripting needed.
#env = env.Clone()
#env.AppendUnique(LIBS = [
#	'xif_rib',
#	'xst_ribclient',
#	])
#test_register_xrls = env.AutoTest(target = 'test_register_xrls',
#                                  source = 'test_register_xrls.cc')
