Commit f11c0a31 authored by Daniel Kamil Kozar's avatar Daniel Kamil Kozar Committed by Jean-Paul Saman

implement array checks for CA descriptor

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent 99536307
<!ELEMENT dr (descriptor*)>
<!ELEMENT descriptor (integer | boolean | insert)*>
<!ELEMENT descriptor (integer | boolean | insert | array)*>
<!ELEMENT integer EMPTY>
<!ELEMENT boolean EMPTY>
<!ELEMENT array EMPTY>
<!ELEMENT insert (begin? | check? | end?)>
<!ELEMENT begin (#PCDATA)>
......@@ -23,3 +25,6 @@
<!ATTLIST boolean name CDATA #IMPLIED>
<!ATTLIST boolean default CDATA #IMPLIED>
<!ATTLIST array name CDATA #IMPLIED>
<!ATTLIST array len_name CDATA #IMPLIED>
......@@ -71,6 +71,7 @@
</insert>
<integer name="i_ca_system_id" bitcount="16" default="0" />
<integer name="i_ca_pid" bitcount="13" default="0" />
<array name="i_private_data" len_name="i_private_length" />
</descriptor>
<descriptor name="system clock" sname="system_clock" fname="SystemClock">
......
......@@ -15,6 +15,9 @@
#include &lt;stdio.h&gt;
#include &lt;stdbool.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;time.h&gt;
#if defined(HAVE_INTTYPES_H)
#include &lt;inttypes.h&gt;
......@@ -43,6 +46,7 @@
int main(void)
{
int i_err = 0;
srand(time(NULL));
<xsl:apply-templates mode="main" />
if(i_err)
......@@ -116,6 +120,15 @@ static int main_<xsl:value-of select="@sname" />_<xsl:value-of select="@msuffix"
BOZO_end_boolean(<xsl:value-of select="@name" />)
</xsl:template>
<xsl:template match="array" mode="check">
/* check <xsl:value-of select="@name" /> */<xsl:apply-templates select=".." mode="init" />
BOZO_begin_array(<xsl:value-of select="@name" />, <xsl:value-of select="@len_name" />)
BOZO_DOJOB(<xsl:value-of select="../@fname" />);
BOZO_check_array(<xsl:value-of select="@name" />, <xsl:value-of select="@len_name" />)
BOZO_CLEAN();
BOZO_end_array(<xsl:value-of select="@name" />)
</xsl:template>
<xsl:template match="insert" mode="check">
<xsl:value-of select="check" />
</xsl:template>
......
......@@ -6,6 +6,9 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -13,8 +16,6 @@
#include <stdint.h>
#endif
#include <sys/types.h>
/* the libdvbpsi distribution defines DVBPSI_DIST */
#ifdef DVBPSI_DIST
#include "../src/dvbpsi.h"
......@@ -39,7 +40,7 @@ static int main_vstream_1(void)
/* check b_multiple_frame_rate */
BOZO_init_boolean(b_multiple_frame_rate, 0);
BOZO_init_integer(i_frame_rate_code, 0);
s_decoded.b_mpeg2 = 0;
s_decoded.b_mpeg2 = false;
BOZO_init_boolean(b_constrained_parameter, 0);
BOZO_init_boolean(b_still_picture, 0);
BOZO_begin_boolean(b_multiple_frame_rate)
......@@ -51,7 +52,7 @@ static int main_vstream_1(void)
/* check i_frame_rate_code */
BOZO_init_boolean(b_multiple_frame_rate, 0);
BOZO_init_integer(i_frame_rate_code, 0);
s_decoded.b_mpeg2 = 0;
s_decoded.b_mpeg2 = false;
BOZO_init_boolean(b_constrained_parameter, 0);
BOZO_init_boolean(b_still_picture, 0);
BOZO_begin_integer(i_frame_rate_code, 4)
......@@ -63,7 +64,7 @@ static int main_vstream_1(void)
/* check b_constrained_parameter */
BOZO_init_boolean(b_multiple_frame_rate, 0);
BOZO_init_integer(i_frame_rate_code, 0);
s_decoded.b_mpeg2 = 0;
s_decoded.b_mpeg2 = false;
BOZO_init_boolean(b_constrained_parameter, 0);
BOZO_init_boolean(b_still_picture, 0);
BOZO_begin_boolean(b_constrained_parameter)
......@@ -75,7 +76,7 @@ static int main_vstream_1(void)
/* check b_still_picture */
BOZO_init_boolean(b_multiple_frame_rate, 0);
BOZO_init_integer(i_frame_rate_code, 0);
s_decoded.b_mpeg2 = 0;
s_decoded.b_mpeg2 = false;
BOZO_init_boolean(b_constrained_parameter, 0);
BOZO_init_boolean(b_still_picture, 0);
BOZO_begin_boolean(b_still_picture)
......@@ -464,6 +465,16 @@ static int main_ca_(void)
BOZO_CLEAN();
BOZO_end_integer(i_ca_pid, 13)
/* check i_private_data */
s_decoded.i_private_length = 0;
BOZO_init_integer(i_ca_system_id, 0);
BOZO_init_integer(i_ca_pid, 0);
BOZO_begin_array(i_private_data, i_private_length)
BOZO_DOJOB(CA);
BOZO_check_array(i_private_data, i_private_length)
BOZO_CLEAN();
BOZO_end_array(i_private_data)
BOZO_END(conditional access);
......@@ -648,6 +659,7 @@ static int main_service_(void)
int main(void)
{
int i_err = 0;
srand(time(NULL));
i_err |= main_vstream_1();
i_err |= main_vstream_2();
......
......@@ -120,3 +120,37 @@
s_decoded.name, p_new_decoded->name); \
i_err = 1; \
}
/* array */
#define BOZO_begin_array(name, len_name) \
if(!i_err) \
{ \
fprintf(stdout, " \"%s\" array check\n", #name); \
i_loop_count = 0; \
do \
{ \
for(size_t i = 0 ; i < i_loop_count ; ++i) s_decoded.name[i] = rand(); \
s_decoded.len_name = i_loop_count;
#define BOZO_end_array(name) \
} while(!i_err && i_loop_count < sizeof(s_decoded.name)); \
fprintf(stdout, "\r iteration count: %22"PRI64d, i_loop_count); \
if(i_err) \
fprintf(stdout, " FAILED !!!\n"); \
else \
fprintf(stdout, " Ok.\n"); \
}
#define BOZO_check_array(name, len_name) \
if( !i_err \
&& (memcmp(s_decoded.name, p_new_decoded->name, s_decoded.len_name) != 0)) \
{ \
fprintf(stderr, "\nError: array %s not equal\n", #name); \
i_err = 1; \
} \
else if(!i_err && s_decoded.len_name != p_new_decoded->len_name) \
{ \
fprintf(stderr, "\nError : array %s sizes not equal : %d -> %d\n", \
#name, s_decoded.len_name, p_new_decoded->len_name); \
i_err = 1; \
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment