Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC TDC 1ns 5cha - Software
Commits
7628823a
Commit
7628823a
authored
Sep 10, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ut: library initialization
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
654b5bab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
3 deletions
+97
-3
Makefile
Makefile
+1
-1
Makefile
unittest/Makefile
+3
-2
fmctdc-ut.c
unittest/fmctdc-ut.c
+93
-0
No files found.
Makefile
View file @
7628823a
...
...
@@ -25,7 +25,7 @@ ZIO_VERSION = $(shell cd $(ZIO_ABS); git describe --always --dirty --long --tags
export
ZIO_VERSION
DIRS
=
$(FMC_BUS_ABS)
$(ZIO_ABS)
kernel lib tools
DIRS
=
$(FMC_BUS_ABS)
$(ZIO_ABS)
kernel lib tools
mamma/lib unittest
kernel
:
$(FMC_BUS_ABS) $(ZIO_ABS)
lib
:
$(ZIO_ABS)
...
...
unittest/Makefile
View file @
7628823a
...
...
@@ -9,8 +9,9 @@ REPO_PARENT ?= ../..
DESTDIR
?=
/usr/local/
LIBTDC
=
../lib/
LIBMAMMA
=
../mamma/lib/
CFLAGS
=
-
ggdb
-I
.
-I
$(LIBTDC
)
-I
../kernel
-Wall
-Werror
$(EXTRACFLAGS)
CFLAGS
=
-
O0
-ggdb
-I
.
-I
$(LIBTDC)
-I
$(LIBMAMMA
)
-I
../kernel
-Wall
-Werror
$(EXTRACFLAGS)
GIT_VERSION
:=
$(
shell
git describe
--dirty
--long
--tags
)
CFLAGS
+=
-DGIT_VERSION
=
"
\"
$(GIT_VERSION)
\"
"
...
...
@@ -19,7 +20,7 @@ LDLIBS = -lfmctdc -lrt
all
:
fmctdc-ut
fmctdc-ut
:
fmctdc-ut.c $(LIBTDC)/libfmctdc.a
fmctdc-ut
:
fmctdc-ut.c $(LIBTDC)/libfmctdc.a
$(LIBMAMMA)/libmamma.a
clean
:
rm
-f
$(TESTS)
test-common.o
unittest/fmctdc-ut.c
View file @
7628823a
...
...
@@ -4,9 +4,102 @@
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <getopt.h>
#include <libgen.h>
#include <stdlib.h>
#include <mamma.h>
#include <fmctdc-lib.h>
struct
fmctdc_test_desc
{
struct
fmctdc_board
*
tdc
;
};
static
int
fmctdc_dev_id
;
/**
* Print help message
* @param[in] name program name
*/
static
void
fmctdc_ut_help
(
char
*
name
)
{
fprintf
(
stderr
,
"%s -D 0x<dev_id>
\n
"
,
basename
(
name
));
}
static
void
fmctdc_param_set_up
(
struct
m_suite
*
m_suite
)
{
struct
fmctdc_test_desc
*
d
;
int
ret
;
ret
=
fmctdc_init
();
m_assert_int_lt
(
0
,
ret
);
d
=
malloc
(
sizeof
(
*
d
));
m_assert_mem_not_null
(
d
);
d
->
tdc
=
fmctdc_open
(
-
1
,
fmctdc_dev_id
);
m_assert_mem_not_null
(
d
->
tdc
);
m_suite
->
private
=
d
;
}
static
void
fmctdc_param_tear_down
(
struct
m_suite
*
m_suite
)
{
struct
fmctdc_test_desc
*
d
=
m_suite
->
private
;
struct
fmctdc_board
*
tdc
=
d
->
tdc
;
int
err
;
free
(
d
);
err
=
fmctdc_close
(
tdc
);
m_assert_int_eq
(
0
,
err
);
fmctdc_exit
();
}
static
void
fmctdc_param_test1
(
struct
m_test
*
m_test
)
{
/* First Test */
}
static
const
char
*
fmctdc_param_test1_desc
=
""
;
int
main
(
int
argc
,
char
*
argv
[])
{
struct
m_test
fmctdc_param_tests
[]
=
{
m_test_desc
(
NULL
,
fmctdc_param_test1
,
NULL
,
fmctdc_param_test1_desc
),
};
struct
m_suite
fmctdc_suite
=
m_suite
(
"FMC TDC test: parameters"
,
0
,
fmctdc_param_tests
,
fmctdc_param_set_up
,
fmctdc_param_tear_down
);
char
opt
;
int
ret
;
while
((
opt
=
getopt
(
argc
,
argv
,
"D:h"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'D'
:
ret
=
sscanf
(
optarg
,
"0x%04x"
,
&
fmctdc_dev_id
);
if
(
ret
!=
1
)
{
fmctdc_ut_help
(
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
break
;
case
'h'
:
case
'?'
:
fmctdc_ut_help
(
argv
[
0
]);
exit
(
EXIT_SUCCESS
);
break
;
}
}
if
(
!
fmctdc_dev_id
)
{
fprintf
(
stderr
,
"Missing device ID options
\n
"
);
fmctdc_ut_help
(
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
m_suite_run
(
&
fmctdc_suite
);
exit
(
EXIT_SUCCESS
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment