#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#

# -*- mode: python; -*-

Import('BuildEnv')
import platform
env = BuildEnv.Clone()
env.Append(CPPPATH = [env['TOP']])
env.Append(CPPPATH = [env['TOP'] + '/tools/sandesh/library/common'])

env.Append(LIBPATH = ['#/' + Dir('..').path,
                      '../../bgp',
                      '../../control-node',
                      '../../db',
                      '../../ifmap',
                      '../../xml',
                      '../../schema',
                      '.'
		      ])

libxmpptest = env.Library('xmpptest',
                         ['xmpp_sample_peer.cc'])

env.Prepend(LIBS = ['task_test', 'gunit', 'xmpp', 'xml', 'pugixml', 'sandesh',
                    'http', 'http_parser', 'curl', 'process_info',
                    'io', 'ssl', 'crypto', 'sandeshvns', 'control_node',
                    'bgp_schema', 'peer_sandesh', 'gendb', 'SimpleAmqpClient',
                    'rabbitmq', 'base', 'boost_regex', 'xmpptest', 'db', 'sandesh'])

env.Append(LIBS = ['ifmapio', 'ifmap_vnc', 'ifmap_server',
                       'ifmap_common', 'cassandra_cql', 'cassandra'])

if platform.system() not in ['Darwin']:
    env.Append(LIBS = ['rt'])

xmpp_server_test = env.UnitTest('xmpp_server_test', ['xmpp_server_test.cc'])
env.Alias('controller/xmpp:xmpp_server_test', xmpp_server_test)

xmpp_regex_test = env.UnitTest('xmpp_regex_test', ['xmpp_regex_test.cc'])
env.Alias('controller/xmpp:xmpp_regex_test', xmpp_regex_test)

xmpp_pubsub_test = env.UnitTest('xmpp_pubsub_test', ['xmpp_pubsub_test.cc'])
env.Alias('controller/xmpp:xmpp_pubsub_test', xmpp_pubsub_test)

xmpp_pubsub_client = env.UnitTest('xmpp_pubsub_client', ['xmpp_pubsub_client.cc'])
env.Alias('controller/xmpp:xmpp_pubsub_client', xmpp_pubsub_client)

xmpp_session_test = env.UnitTest('xmpp_session_test', ['xmpp_session_test.cc'])
env.Alias('controller/xmpp:xmpp_session_test', xmpp_session_test)

xmpp_client_standalone_test = env.UnitTest('xmpp_client_standalone_test',
                                           ['xmpp_client_standalone.cc'])
env.Alias('controller/xmpp:xmpp_client_standalone_test', xmpp_client_standalone_test)

xmpp_server_standalone_test = env.UnitTest('xmpp_server_standalone_test',
                                           ['xmpp_server_standalone.cc'])
env.Alias('controller/xmpp:xmpp_server_standalone_test', xmpp_server_standalone_test)

xmpp_server_sm_test = env.UnitTest('xmpp_server_sm_test',['xmpp_server_sm_test.cc'])
env.Alias('controller/xmpp:xmpp_server_sm_test', xmpp_server_sm_test)

xmpp_server_auth_sm_test = env.UnitTest('xmpp_server_auth_sm_test',
                                        ['xmpp_server_auth_sm_test.cc'])
env.Alias('controller/xmpp:xmpp_server_auth_sm_test', xmpp_server_auth_sm_test)

xmpp_client_sm_test = env.UnitTest('xmpp_client_sm_test', ['xmpp_client_sm_test.cc'])
env.Alias('controller/xmpp:xmpp_client_sm_test', xmpp_client_sm_test)

xmpp_client_auth_sm_test = env.UnitTest('xmpp_client_auth_sm_test',
                                        ['xmpp_client_auth_sm_test.cc'])
env.Alias('controller/xmpp:xmpp_client_auth_sm_test', xmpp_client_auth_sm_test)

xmpp_stream_message_client_test = env.UnitTest('xmpp_stream_message_client_test',
                                               ['xmpp_stream_message_client.cc'])
env.Alias('controller/xmpp:xmpp_stream_message_client_test', xmpp_stream_message_client_test)

xmpp_stream_message_server_test = env.UnitTest('xmpp_stream_message_server_test',
                                               ['xmpp_stream_message_server.cc'])
env.Alias('controller/xmpp:xmpp_stream_message_server_test', xmpp_stream_message_server_test)


test_suite = [
    xmpp_client_sm_test,
    xmpp_pubsub_test,
    xmpp_regex_test,
    xmpp_server_sm_test,
    xmpp_server_test,
    xmpp_session_test,
    xmpp_server_auth_sm_test,
    xmpp_client_auth_sm_test
]

flaky_test_suite = [
    xmpp_stream_message_client_test,
    xmpp_stream_message_server_test,
]

test = env.TestSuite('xmpp-test', test_suite)
env.Alias('controller/src/xmpp:test', test)

flaky_test = env.TestSuite('xmpp-flaky-test', flaky_test_suite)
env.Alias('controller/src/xmpp:flaky-test', flaky_test)
 
env.Alias('controller/src/xmpp:all-test', [test, flaky_test])

Return('test_suite')
