/*
 * Copyright (c) 2017 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above
 *    copyright notice, this list of conditions and the following
 *    disclaimer in the documentation and/or other materials provided
 *    with the distribution.
 *  * Neither the name of The Linux Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>

#include "IPAInterruptsTestFixture.h"
#include "Constants.h"
#include "TestsUtils.h"
#include "linux/msm_ipa.h"

/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////

class SuspendTestDeferred: public IPAInterruptsTestFixture {
public:

	SuspendTestDeferred() {
		m_name = "SuspendTestDeferred";
		m_description = "This test will send data on a suspended pipe(Deferred context) ";
		Register(*this);
	}

	bool Setup()
	{
		bool bRetVal = true;

		/*Set the configuration to support USB->IPA and IPA->USB pipes.*/
		ConfigureScenario(IPA_TEST_CONFIGURATION_19);

		RegSuspendHandler(true,true,0);

		/*Initialize the pipe for all the tests -
		 * this will open the inode which represents the pipe.
		 */
		bRetVal &= m_IpaToUsbPipe.Init();
		bRetVal &= m_UsbToIpaPipe.Init();
		return bRetVal;
	}
};


class SuspendTest: public IPAInterruptsTestFixture {
public:

	SuspendTest() {
		m_name = "SuspendTest";
		m_description = "This test will send data on a suspended pipe";
		Register(*this);
	}

	bool Setup()
	{
		bool bRetVal = true;

		/*Set the configuration to support USB->IPA and IPA->USB pipes.*/
		ConfigureScenario(IPA_TEST_CONFIGURATION_19);

		RegSuspendHandler(false,true,0);

		/*Initialize the pipe for all the tests -
		 * this will open the inode which represents the pipe.
		 */
		bRetVal &= m_IpaToUsbPipe.Init();
		bRetVal &= m_UsbToIpaPipe.Init();
		return bRetVal;
	}
};

static SuspendTest suspendTest;
static SuspendTestDeferred suspendTestDeferred;
/////////////////////////////////////////////////////////////////////////////////
//                                  EOF                                      ////
/////////////////////////////////////////////////////////////////////////////////
