summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Jutteau2010-09-20 14:21:52 +0200
committerJerome Jutteau2010-09-20 18:19:19 +0200
commit821b531943401065533251e53ce338fd71e12855 (patch)
tree9ff288aa9529900f9122293b0c9c66491f37bab7
parent8766a519b23bb1de09826d8333f27b61d5f0a861 (diff)
cesar/ce/tx: fix tone maps cleaning, closes #1818
-rw-r--r--cesar/ce/tx/src/tx.c5
-rw-r--r--cesar/ce/tx/test/Makefile5
-rw-r--r--cesar/ce/tx/test/src/test_tm.c103
-rw-r--r--cesar/common/tests/tests1
4 files changed, 112 insertions, 2 deletions
diff --git a/cesar/ce/tx/src/tx.c b/cesar/ce/tx/src/tx.c
index 306aa32607..dda4395cd7 100644
--- a/cesar/ce/tx/src/tx.c
+++ b/cesar/ce/tx/src/tx.c
@@ -18,6 +18,7 @@
#include "cp/mme.h"
#include "cp/sta/mgr/sta_own_data.h"
#include "cp/sta/mgr/sta_mgr.h"
+#include "mac/common/interval.h"
#include "mac/common/defs.h"
#include "ce/tx/inc/tx.h"
#include "ce/tx/mme.h"
@@ -120,7 +121,9 @@ ce_tx_clean_tonemaps (tonemaps_t *tone_maps)
tone_maps->default_tmi == TONEMAP_INDEX_INITIAL_ERROR)
{
/* Reset interval. */
- tone_maps->intervals->intervals_nb = 0;
+ mac_interval_clear (tone_maps);
+ mac_interval_commit_changes (tone_maps);
+
/* Go through each tone map. */
uint i;
for (i = TONEMAP_INDEX_NEGOTIATED_FIRST; i < TONEMAP_INDEX_NB;
diff --git a/cesar/ce/tx/test/Makefile b/cesar/ce/tx/test/Makefile
index 44374d5744..83caf147f9 100644
--- a/cesar/ce/tx/test/Makefile
+++ b/cesar/ce/tx/test/Makefile
@@ -10,7 +10,7 @@ common_MODULES = lib mac/common ce/tx cp/sta/mgr \
cp/cco/action/stub ce/common cp/msg/stub bsu/stub
# For host program.
-HOST_PROGRAMS = test_expiration test_mme
+HOST_PROGRAMS = test_expiration test_mme test_tm
test_expiration_SOURCES = test_expiration.c mme.c stub.c
test_expiration_MODULES = $(common_MODULES)
@@ -18,5 +18,8 @@ test_expiration_MODULES = $(common_MODULES)
test_mme_SOURCES = test_mme.c mme.c stub.c
test_mme_MODULES = $(common_MODULES)
+test_tm_SOURCES = test_tm.c stub.c
+test_tm_MODULES = $(common_MODULES)
+
# Include main Makefile.
include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/tx/test/src/test_tm.c b/cesar/ce/tx/test/src/test_tm.c
new file mode 100644
index 0000000000..5287e913b5
--- /dev/null
+++ b/cesar/ce/tx/test/src/test_tm.c
@@ -0,0 +1,103 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/tx/test/src/test_tm.c
+ * \brief Test function for tone maps cleaning.
+ * \ingroup test
+ */
+
+#include "common/std.h"
+#include "ce/tx/inc/tx.h"
+#include "lib/test.h"
+#include "lib/blk.h"
+#include "mac/common/tonemap.h"
+#include "mac/common/interval.h"
+
+void
+ce_test_tm_clean (test_t t)
+{
+ tonemaps_t *tms = tonemaps_alloc ();
+ test_begin (t, "Check if a tonemaps_t is cleaned ")
+ {
+ uint version;
+ uint nb;
+ uint i;
+
+ for (i = 0; i < 4; i++)
+ {
+ version = 42;
+ nb = 0;
+
+ /* Configure default tmi for deferent cases. */
+ switch (i)
+ {
+ case 0:
+ tms->default_tmi = TONEMAP_INDEX_INITIAL_START;
+ break;
+ case 1:
+ tms->default_tmi = TONEMAP_INDEX_INITIAL_ERROR;
+ break;
+ case 2:
+ tms->default_tmi = TONEMAP_INDEX_INITIAL_SOUND_COMPLETE;
+ break;
+ case 3:
+ tms->default_tmi = TONEMAP_INDEX_NEGOTIATED_FIRST;
+ break;
+ }
+
+ /* Makes some changes and commit. */
+ test_fail_if (mac_interval_append (tms, ++nb, nb) == 0);
+ test_fail_if (mac_interval_append (tms, ++nb, nb) == 0);
+ test_fail_if (mac_interval_append (tms, ++nb, nb) == 0);
+ mac_interval_commit_changes (tms);
+
+ /* Set version. */
+ tms->intervals->version = version;
+
+ /* Interval nb should not be 0. */
+ test_fail_if (tms->intervals->intervals_nb != nb);
+
+ /* Tests tone maps cleaning. */
+ ce_tx_clean_tonemaps (tms);
+
+ if (tms->default_tmi == TONEMAP_INDEX_NEGOTIATED_FIRST)
+ {
+ /* Check that the interval number is not reset. */
+ test_fail_if (tms->intervals->intervals_nb == 0);
+ /* Check that the version number has not been increased. */
+ test_fail_if (tms->intervals->version != version);
+ }
+ else
+ {
+ /* Check that interval number is reset. */
+ test_fail_if (tms->intervals->intervals_nb != 0);
+ /* Check that the version number increased. */
+ test_fail_if (tms->intervals->version != version + 1);
+ }
+ }
+ } test_end;
+ /* Clean. */
+ tonemaps_release (tms);
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t t;
+ test_init (t, argc, argv);
+
+ ce_test_tm_clean (t);
+
+ test_begin (t, "memory")
+ {
+ test_fail_unless (blk_check_memory ());
+ } test_end;
+
+ test_result (t);
+ return test_nb_failed (t) == 0 ? 0 : 1;
+}
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index 5b5640443f..7a0f37eec5 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -259,6 +259,7 @@ ce/tx/test:
make: make COV=y
cov ce_tx_test_mme: ./obj/test_mme
cov ce_tx_test_expiration: ./obj/test_expiration
+cov ce_tx_test_tm: ./obj/test_tm
ce/rx/test:
make: make COV=y