Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Guruprasad Hegde
TAS-OPT
Commits
43210d6d
Commit
43210d6d
authored
Oct 24, 2019
by
guruhegde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test to check struct accessibility
parent
12bcce8d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
1 deletion
+101
-1
test/unittests/batchMaker_test.cpp
test/unittests/batchMaker_test.cpp
+19
-0
test/unittests/inputs/batchmaker_test6.c
test/unittests/inputs/batchmaker_test6.c
+33
-0
test/unittests/inputs/batchmaker_test6_main.c
test/unittests/inputs/batchmaker_test6_main.c
+48
-0
test/unittests/inputs/fast_flows.c
test/unittests/inputs/fast_flows.c
+1
-1
No files found.
test/unittests/batchMaker_test.cpp
View file @
43210d6d
...
...
@@ -235,6 +235,25 @@ TEST_CASE("input parameter struct type") {
REQUIRE
(
BF
->
arg_size
()
==
4
);
}
{
std
::
string
functionName
=
"struct_ptr_flow_state"
;
// Function with 1 argument and int return type.
auto
F
=
M
->
getFunction
(
functionName
);
REQUIRE
(
F
->
getReturnType
()
==
Type
::
getInt32Ty
(
C
));
REQUIRE
(
F
->
arg_size
()
==
1
);
REQUIRE
(
M
->
getFunction
(
functionName
+
string
(
"_batch"
))
==
nullptr
);
BatchMaker
BM
(
F
);
BM
.
run
();
// Function with 4 arguments and void return type.
auto
BF
=
M
->
getFunction
(
functionName
+
string
(
"_batch"
));
REQUIRE
(
BF
!=
nullptr
);
REQUIRE
(
BF
->
getReturnType
()
==
Type
::
getVoidTy
(
C
));
REQUIRE
(
BF
->
arg_size
()
==
3
);
}
writeToAsmFile
(
*
M
);
// MainObject contains checks to verify the correctness of transformation.
...
...
test/unittests/inputs/batchmaker_test6.c
View file @
43210d6d
#include <stdio.h>
#define BATCH_ARG __attribute__((annotate("batch_arg")))
#define TAS_BATCH_START int TAS_batch_start __attribute__((annotate("batch_begin")));
#define TAS_BATCH_END int TAS_batch_end __attribute__((annotate("batch_end")));
...
...
@@ -7,6 +9,19 @@ struct packet {
int
field2
;
};
struct
flow_group
{
int
p
;
int
q
;
};
struct
flow_state
{
int
a
;
int
b
;
int
c
;
int
d
;
struct
flow_group
fg
;
};
int
struct_type_fn
(
struct
packet
a
BATCH_ARG
,
int
b
BATCH_ARG
)
{
int
c
,
d
;
TAS_BATCH_START
...
...
@@ -52,3 +67,21 @@ int struct_ptr_type_fn(struct packet * a BATCH_ARG, int b BATCH_ARG) {
d
=
c
*
2
;
return
1
;
}
int
struct_ptr_flow_state
(
struct
flow_state
*
a
BATCH_ARG
)
{
struct
flow_state
*
fs
;
int
i
,
j
,
k
;
TAS_BATCH_START
fs
=
a
;
i
=
0
;
j
=
0
;
k
=
0
;
if
(
fs
->
a
!=
0
&&
fs
->
b
!=
1
&&
fs
->
c
!=
2
&&
fs
->
d
!=
3
&&
fs
->
fg
.
p
!=
4
&&
fs
->
fg
.
q
!=
5
)
return
-
1
;
return
0
;
}
test/unittests/inputs/batchmaker_test6_main.c
View file @
43210d6d
...
...
@@ -6,6 +6,18 @@ struct packet {
int
field2
;
};
struct
flow_group
{
int
p
;
int
q
;
};
struct
flow_state
{
int
a
;
int
b
;
int
c
;
int
d
;
struct
flow_group
fg
;
};
int
struct_type_fn
(
struct
packet
a
,
int
b
);
void
struct_type_fn_batch
(
struct
packet
*
,
int
*
,
int
,
int
*
);
...
...
@@ -13,6 +25,8 @@ void struct_type_multi_ret_fn(struct packet a, int b);
void
struct_type_multi_ret_fn_batch
(
struct
packet
*
,
int
*
,
int
);
int
struct_ptr_type_fn
(
struct
packet
*
,
int
);
void
struct_ptr_type_fn_batch
(
struct
packet
**
,
int
*
,
int
,
int
*
);
int
struct_ptr_flow_state
(
struct
flow_state
*
);
void
struct_ptr_flow_state_batch
(
struct
flow_state
**
,
int
,
int
*
);
int
main
()
{
int
rc
=
0
;
...
...
@@ -80,5 +94,39 @@ int main() {
}
}
{
// struct_ptr_type_fn
// Check the flow state value set
const
int
batch_size
=
4
;
struct
flow_state
*
aptr
[
batch_size
];
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
aptr
[
i
]
=
(
struct
flow_state
*
)
malloc
(
sizeof
(
struct
flow_state
));
aptr
[
i
]
->
a
=
0
;
aptr
[
i
]
->
b
=
1
;
aptr
[
i
]
->
c
=
2
;
aptr
[
i
]
->
d
=
3
;
aptr
[
i
]
->
fg
.
p
=
4
;
aptr
[
i
]
->
fg
.
q
=
5
;
}
int
ret
[
batch_size
]
=
{
0
};
int
ret_batch
[
batch_size
]
=
{
0
};
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
ret
[
i
]
=
struct_ptr_flow_state
(
aptr
[
i
]);
struct_ptr_flow_state_batch
(
aptr
,
batch_size
,
ret_batch
);
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
if
(
aptr
[
i
]
->
a
!=
0
&&
aptr
[
i
]
->
b
!=
1
)
{
rc
--
;
break
;
}
}
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
if
(
ret
[
i
]
!=
ret_batch
[
i
])
{
rc
--
;
break
;
}
}
}
return
rc
;
}
test/unittests/inputs/fast_flows.c
View file @
43210d6d
...
...
@@ -281,7 +281,7 @@ void fast_flows_packet_pfbufs(struct dataplane_context *ctx,
/* Received packet */
int
fast_flows_packet
(
struct
dataplane_context
*
ctx
,
struct
network_buf_handle
*
nbh
BATCH_ARG
,
void
*
fsp
BATCH_ARG
,
struct
tcp_opts
opts
BATCH_ARG
,
struct
network_buf_handle
*
nbh
BATCH_ARG
,
struct
flextcp_pl_flowst
*
fsp
BATCH_ARG
,
struct
tcp_opts
opts
BATCH_ARG
,
uint32_t
ts
)
TAS_BLOCK_PREDICATION
{
struct
pkt_tcp
*
p
;
...
...
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