Skip to content

Commit 8ec45cd

Browse files
committed
add test
1 parent 6ec6fc3 commit 8ec45cd

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/platforms/esp32/test/main/test_erl_sources/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function(compile_erlang module_name)
3838
endfunction()
3939

4040
compile_erlang(test_esp_partition)
41+
compile_erlang(test_esp_timer_get_time)
4142
compile_erlang(test_file)
4243
compile_erlang(test_wifi_example)
4344
compile_erlang(test_list_to_atom)
@@ -60,6 +61,7 @@ add_custom_command(
6061
COMMAND HostAtomVM-prefix/src/HostAtomVM-build/tools/packbeam/PackBEAM -i esp32_test_modules.avm
6162
HostAtomVM-prefix/src/HostAtomVM-build/libs/atomvmlib.avm
6263
test_esp_partition.beam
64+
test_esp_timer_get_time.beam
6365
test_file.beam
6466
test_wifi_example.beam
6567
test_list_to_atom.beam
@@ -79,6 +81,7 @@ add_custom_command(
7981
DEPENDS
8082
HostAtomVM
8183
"${CMAKE_CURRENT_BINARY_DIR}/test_esp_partition.beam"
84+
"${CMAKE_CURRENT_BINARY_DIR}/test_esp_timer_get_time.beam"
8285
"${CMAKE_CURRENT_BINARY_DIR}/test_wifi_example.beam"
8386
"${CMAKE_CURRENT_BINARY_DIR}/test_file.beam"
8487
"${CMAKE_CURRENT_BINARY_DIR}/test_list_to_atom.beam"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
%
2+
% This file is part of AtomVM.
3+
%
4+
% Copyright 2023 Davide Bettio <davide@uninstall.it>
5+
%
6+
% Licensed under the Apache License, Version 2.0 (the "License");
7+
% you may not use this file except in compliance with the License.
8+
% You may obtain a copy of the License at
9+
%
10+
% http://www.apache.org/licenses/LICENSE-2.0
11+
%
12+
% Unless required by applicable law or agreed to in writing, software
13+
% distributed under the License is distributed on an "AS IS" BASIS,
14+
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
% See the License for the specific language governing permissions and
16+
% limitations under the License.
17+
%
18+
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
19+
%
20+
21+
-module(test_esp_timer_get_time).
22+
23+
-export([start/0]).
24+
25+
start() ->
26+
T = esp:timer_get_time(),
27+
test_pos_int(T).
28+
29+
test_pos_int(X) when is_integer(X) andalso X >= 0 ->
30+
ok;
31+
test_pos_int(X) ->
32+
error.
33+

src/platforms/esp32/test/main/test_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ TEST_CASE("test_esp_partition", "[test_run]")
180180
TEST_ASSERT(term_to_int(ret_value) == 0);
181181
}
182182

183+
TEST_CASE("test_esp_timer_get_time", "[test_run]")
184+
{
185+
term ret_value = avm_test_case("test_esp_timer_get_time.beam");
186+
TEST_ASSERT(ret_value == OK_ATOM);
187+
}
188+
183189
// SDMMC works all esp-idf versions for esp32 - still no support c3.
184190
// only run in QEMU (eg. OPENETH configured)
185191
#if !CONFIG_IDF_TARGET_ESP32C3 && CONFIG_ETH_USE_OPENETH

0 commit comments

Comments
 (0)