1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--  Copyright (c) 2014, STMicroelectronics International N.V. -->
4<!--  All rights reserved. -->
5<!--  Copyright (c) 2020, Linaro Limied-->
6<!--  -->
7<!--  Redistribution and use in source and binary forms, with or without -->
8<!--  modification, are permitted provided that the following conditions are met: -->
9<!--  -->
10<!--  1. Redistributions of source code must retain the above copyright notice, -->
11<!--  this list of conditions and the following disclaimer. -->
12<!--  -->
13<!--  2. Redistributions in binary form must reproduce the above copyright notice, -->
14<!--  this list of conditions and the following disclaimer in the documentation -->
15<!--  and/or other materials provided with the distribution. -->
16<!--  -->
17<!--  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -->
18<!--  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -->
19<!--  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -->
20<!--  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -->
21<!--  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -->
22<!--  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -->
23<!--  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -->
24<!--  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -->
25<!--  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -->
26<!--  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -->
27<!--  POSSIBILITY OF SUCH DAMAGE. -->
28
29<xsl:stylesheet version="1.0"
30xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
31
32<xsl:output method="text"/>
33<xsl:strip-space elements="*"/>
34<xsl:param name="target"/>
35
36<xsl:template match="package">
37<xsl:text>
38/*
39 * Copyright (c) 2014, STMicroelectronics International N.V.
40 * Copyright (c) 2020, Linaro Limited
41 *
42 * This program is free software; you can redistribute it and/or modify
43 * it under the terms of the GNU General Public License Version 2 as
44 * published by the Free Software Foundation.
45 *
46 * This program is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 * GNU General Public License for more details.
50 *
51 * You should have received a copy of the GNU General Public License along
52 * with this program; if not, write to the Free Software Foundation, Inc.,
53 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
54 */
55
56
57#include "xml_client_api.h"
58</xsl:text>
59
60<xsl:for-each select="initial-state/scenario">
61/*<xsl:value-of select="substring(substring-after(./@name, '('), 0, 9)" />*/
62static void gp_test_teec_<xsl:value-of select="position()+10000" />(ADBG_Case_t *c __maybe_unused)
63{
64<xsl:for-each select="./preamble/call/operation">
65    <xsl:apply-templates select="."></xsl:apply-templates>
66</xsl:for-each>
67<xsl:for-each select="./body/call/operation">
68    <xsl:apply-templates select="."></xsl:apply-templates>
69</xsl:for-each>
70<xsl:for-each select="./postamble/call/operation">
71    <xsl:apply-templates select="."></xsl:apply-templates>
72</xsl:for-each>
73}
74</xsl:for-each>
75
76<xsl:for-each select="initial-state/scenario">
77<xsl:variable name="position" select="position()+10000" />
78ADBG_CASE_DEFINE(gp, <xsl:value-of select="$position" />, gp_test_teec_<xsl:value-of select="$position" /><xsl:text>, "</xsl:text><xsl:value-of select="substring(substring-after(./@name, '('), 0, 9)" /><xsl:text>");</xsl:text>
79</xsl:for-each>
80</xsl:template>
81
82<xsl:template match="operation">
83<xsl:choose>
84<xsl:when test="(contains(./argument[last()]/parameter/@name, 'xpected') and not(contains(./@name, 'Invoke')) and not(contains(./@name, 'checkMemoryContent_sharedMemory')) and not(contains(./@name, 'checkMemoryContent_tmpMemory')) and not(contains(./@name, 'checkContent_Parameter_value')) and not(contains(./@name, 'OpenSession')) and not(contains(./@name, 'InitializeContext')))">    ADBG_EXPECT(c, <xsl:for-each select="./argument"><xsl:if test="position()=last()"><xsl:apply-templates select="value"></xsl:apply-templates></xsl:if></xsl:for-each>, <xsl:apply-templates select="./@name"></xsl:apply-templates><xsl:for-each select="./argument/value"><xsl:if test="position()>1 and not(position()=last())">, </xsl:if><xsl:if test="not(position()=last())"><xsl:apply-templates select="."></xsl:apply-templates></xsl:if>
85        </xsl:for-each>));
86</xsl:when>
87<xsl:otherwise>
88<xsl:text>    </xsl:text><xsl:apply-templates select="./@name"></xsl:apply-templates><xsl:for-each select="./argument"><xsl:if test="position()>1">, </xsl:if>
89            <xsl:apply-templates select="./value"></xsl:apply-templates>
90        </xsl:for-each>);
91</xsl:otherwise>
92</xsl:choose>
93</xsl:template>
94
95<xsl:template match="value">
96<xsl:choose>
97<xsl:when test="(contains(./@name, 'UUID'))"><xsl:text>&amp;</xsl:text><xsl:value-of select="./@name" />
98</xsl:when>
99<xsl:otherwise>
100<!--xsl:text>&amp;</xsl:text--><xsl:value-of select="./@name" />
101</xsl:otherwise>
102</xsl:choose>
103</xsl:template>
104
105<xsl:template match="parameter">
106        <xsl:value-of select="./@name" />
107</xsl:template>
108
109<xsl:template match="@name">
110<xsl:choose>
111<xsl:when test=".='InitializeContext'"><xsl:text>XML_</xsl:text><xsl:value-of select="." /><xsl:text>(c, </xsl:text>
112</xsl:when>
113<xsl:when test=".='OpenSession'"><xsl:text>XML_</xsl:text><xsl:value-of select="." /><xsl:text>(c, </xsl:text>
114</xsl:when>
115<xsl:when test=".='Invoke_Remember_Expected_ParamTypes'"><xsl:text>INVOKE_REMEMBER_EXP_PARAM_TYPES</xsl:text><xsl:text>(</xsl:text>
116</xsl:when>
117<xsl:when test=".='Invoke_Store_Expected_Param_Info'"><xsl:text>INVOKE_STORE_EXP_PARAM_INFO</xsl:text><xsl:text>(</xsl:text>
118</xsl:when>
119<xsl:when test=".='AllocateSharedMemory'"><xsl:value-of select="." /><xsl:text>(</xsl:text>
120</xsl:when>
121<xsl:when test=".='RegisterSharedMemory'"><xsl:value-of select="." /><xsl:text>(</xsl:text>
122</xsl:when>
123<xsl:when test=".='AllocateTempMemory'"><xsl:value-of select="." /><xsl:text>(</xsl:text>
124</xsl:when>
125<xsl:when test=".='ReleaseTempMemory'"><xsl:value-of select="." /><xsl:text>(</xsl:text>
126</xsl:when>
127<xsl:when test=".='PARAM_TYPES'"><xsl:text>OPERATION_TEEC_PARAM_TYPES</xsl:text><xsl:text>(</xsl:text>
128</xsl:when>
129<xsl:when test="(contains(., 'Invoke') and not(contains(., 'Remember_Expected_ParamTypes')))"><xsl:text>XML_InvokeCommand</xsl:text><xsl:text>(c, </xsl:text>
130</xsl:when>
131<xsl:otherwise>
132<xsl:text>TEEC_</xsl:text><xsl:value-of select="." /><xsl:text>(</xsl:text>
133</xsl:otherwise>
134</xsl:choose>
135</xsl:template>
136
137</xsl:stylesheet>
138