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 Limited -->
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 *
41 * This program is free software; you can redistribute it and/or modify
42 * it under the terms of the GNU General Public License Version 2 as
43 * published by the Free Software Foundation.
44 *
45 * This program is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU General Public License for more details.
49 *
50 * You should have received a copy of the GNU General Public License along
51 * with this program; if not, write to the Free Software Foundation, Inc.,
52 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
53 */
54
55
56#include "xml_timearithm_api.h"
57
58
59</xsl:text>
60<xsl:for-each select="initial-state/scenario">
61/*<xsl:value-of select="substring(substring-after(./@name, '('), 0, 9)" />*/
62static void xtest_tee_<xsl:value-of select="position()+40000" />(ADBG_Case_t *c)
63{
64
65<xsl:for-each select="./preamble/call/operation">
66    <xsl:apply-templates select="."></xsl:apply-templates>
67</xsl:for-each>
68<xsl:for-each select="./body/call/operation|./body/call/observations/operation">
69    <xsl:apply-templates select="."></xsl:apply-templates>
70</xsl:for-each>
71<xsl:for-each select="./verification/call/operation">
72    <xsl:apply-templates select="."></xsl:apply-templates>
73</xsl:for-each>
74<xsl:for-each select="./postamble/call/operation">
75    <xsl:apply-templates select="."></xsl:apply-templates>
76</xsl:for-each>
77}
78</xsl:for-each>
79
80<xsl:for-each select="initial-state/scenario">
81<xsl:variable name="position" select="position()+40000" />
82ADBG_CASE_DEFINE(gp, <xsl:value-of select="$position" />, xtest_tee_<xsl:value-of select="$position" /><xsl:text>, "</xsl:text><xsl:value-of select="substring(substring-after(./@name, '('), 0, 9)" /><xsl:text>");</xsl:text>
83</xsl:for-each>
84</xsl:template>
85
86<xsl:template match="operation">
87<xsl:choose>
88<!--Call an operation with ADBG_EXPECT() macro.-->
89<xsl:when test="(contains(./argument[last()]/parameter/@name, 'xpected') and not(contains(./@name, 'OpenSession')) and not(contains(./@name, 'InitializeContext')))">        ADBG_EXPECT_TEEC_RESULT(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>
90        </xsl:for-each>));
91</xsl:when>
92<xsl:otherwise>
93<xsl:text>        </xsl:text><xsl:apply-templates select="./@name"></xsl:apply-templates><xsl:for-each select="./argument"><xsl:if test="position()>1">, </xsl:if>
94            <xsl:apply-templates select="./value"></xsl:apply-templates>
95        </xsl:for-each>);
96</xsl:otherwise>
97</xsl:choose>
98
99</xsl:template>
100
101<xsl:template match="value">
102<xsl:choose>
103<!--xsl:when test=".='IN_sharedMem_size'"><xsl:value-of select="./@name" />
104</xsl:when-->
105<xsl:when test="((contains(./@name, 'UUID')) and not(contains(./@name, 'VALUE_PREDEFINED_UUID')) and not(contains(./@name, 'CMD_TEE_GetPropertyAsUUID_withoutEnum')))"><xsl:text>&amp;</xsl:text><xsl:value-of select="./@name" />
106</xsl:when>
107<xsl:when test="(../type/@name='ALL_TEE_NAMES' and ./@name='NULL')"><xsl:text>xtest_tee_name</xsl:text>
108</xsl:when>
109<xsl:when test="(../type/@name='ALL_STORED_VALUES_ROLES')"><xsl:text>STORED_VALUE_</xsl:text><xsl:value-of select="./@name" />
110</xsl:when>
111<xsl:when test="(contains(../type/@name, 'ALL_BIG_INT_VALUES'))"><xsl:value-of select="./@name" /><xsl:text>, sizeof(</xsl:text><xsl:value-of select="./@name" /><xsl:text>)</xsl:text>
112</xsl:when>
113<xsl:otherwise>
114<!--xsl:text>&amp;</xsl:text--><xsl:value-of select="./@name" />
115</xsl:otherwise>
116</xsl:choose>
117</xsl:template>
118
119<xsl:template match="parameter">
120        <xsl:value-of select="./@name" />
121</xsl:template>
122
123<xsl:template match="@name">
124<xsl:choose>
125<xsl:when test=".='RequestCancellation'"><xsl:value-of select="." /><xsl:text>(</xsl:text>
126</xsl:when>
127<xsl:when test=".='InitializeContext'"><xsl:text>XML_</xsl:text><xsl:value-of select="." /><xsl:text>(c, </xsl:text>
128</xsl:when>
129<xsl:when test=".='OpenSession'"><xsl:text>XML_</xsl:text><xsl:value-of select="." /><xsl:text>(c, </xsl:text>
130</xsl:when>
131<xsl:when test=".='SelectApp'"><xsl:text>TEEC_</xsl:text><xsl:value-of select="." /><xsl:text>(</xsl:text>
132</xsl:when>
133<xsl:when test=".='CloseSession'"><xsl:text>TEEC_</xsl:text><xsl:value-of select="." /><xsl:text>(</xsl:text>
134</xsl:when>
135<xsl:when test=".='FinalizeContext'"><xsl:text>TEEC_</xsl:text><xsl:value-of select="." /><xsl:text>(</xsl:text>
136</xsl:when>
137<xsl:when test=".='createThread'"><xsl:text>TEEC_</xsl:text><xsl:value-of select="." /><xsl:text>(</xsl:text>
138</xsl:when>
139<xsl:when test=".='Test_Tool_Erase_Persistent_Time'"><xsl:value-of select="." /><xsl:text>(c, SESSION01, CMD_TEE_SetTAPersistentTime_and_GetTAPersistentTime</xsl:text>
140</xsl:when>
141<xsl:when test=".='PARAM_TYPES'"><xsl:text>OPERATION_TEEC_</xsl:text><xsl:value-of select="." /><xsl:text>(</xsl:text>
142</xsl:when>
143<xsl:when test=".='SetUp_TEE'"><xsl:text>TEEC_SetUp_TEE(</xsl:text> </xsl:when>
144<xsl:when test=".='TearDown_TEE'"><xsl:text>TEEC_TearDown_TEE(</xsl:text> </xsl:when>
145<xsl:otherwise>
146<xsl:value-of select="." /><xsl:text>(c, </xsl:text>
147</xsl:otherwise>
148</xsl:choose>
149</xsl:template>
150
151</xsl:stylesheet>
152