This commit is contained in:
Qingsong Chen 2026-02-06 18:46:41 +08:00 committed by GitHub
commit 754d1cb032
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 566 additions and 4 deletions

View File

@ -17,6 +17,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test:
- name: hello
disk_size: 6144
- name: python
disk_size: 8192
name: Test ${{ matrix.test.name }}
timeout-minutes: 60
steps:
# In the subsequent tests, a relatively large disk (4GB) will be created to install AsterNixOS.
# Standard GitHub runners may encounter "insufficient disk space" errors.
@ -32,12 +41,11 @@ jobs:
remove_haskell: true
remove_tool_cache: true
- uses: actions/checkout@v4
- name: Run the hello test on AsterNixOS
timeout-minutes: 30
- name: Run the ${{ matrix.test.name }} test on AsterNixOS
uses: addnab/docker-run-action@v3
with:
image: asterinas/asterinas:0.17.0-20260114
options: --privileged -v /dev:/dev -v ${{ github.workspace }}:/root/asterinas
run: |
make nixos NIXOS_TEST_SUITE=hello NIXOS_DISK_SIZE_IN_MB=6144
make run_nixos NIXOS_TEST_SUITE=hello
make nixos NIXOS_TEST_SUITE=${{ matrix.test.name }} NIXOS_DISK_SIZE_IN_MB=${{ matrix.test.disk_size }}
make run_nixos NIXOS_TEST_SUITE=${{ matrix.test.name }}

7
test/nixos/Cargo.lock generated
View File

@ -266,6 +266,13 @@ dependencies = [
"nixos-test-framework",
]
[[package]]
name = "test-python"
version = "0.1.0"
dependencies = [
"nixos-test-framework",
]
[[package]]
name = "thiserror"
version = "2.0.17"

View File

@ -0,0 +1,9 @@
[package]
name = "test-python"
version.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true
[dependencies]
nixos-test-framework.workspace = true

View File

@ -0,0 +1,5 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = with pkgs; [ python312 ];
}

View File

@ -0,0 +1,34 @@
// SPDX-License-Identifier: MPL-2.0
//! The test suite for Python regression tests on Asterinas NixOS.
//!
//! # Document maintenance
//!
//! An application's test suite and its "Verified Usage" section in Asterinas Book
//! should always be kept in sync.
//! So whenever you modify the test suite,
//! review the documentation and see if should be updated accordingly.
use nixos_test_framework::*;
nixos_test_main!();
#[nixos_test]
fn python(nixos_shell: &mut Session) -> Result<(), Error> {
nixos_shell.run_cmd("curl https://www.python.org/ftp/python/3.12.12/Python-3.12.12.tar.xz -o Python-3.12.12.tar.xz")?;
nixos_shell.run_cmd("tar xf Python-3.12.12.tar.xz")?;
nixos_shell.run_cmd("export PYTHONPATH=$PWD/Python-3.12.12/Lib")?;
let testcases = std::fs::read_to_string("src/testcases.txt")?;
for line in testcases.lines() {
let line = line.trim();
if line.is_empty() || line.starts_with("#") {
continue;
}
let cmd = format!("python -m test -u all {}", line);
nixos_shell.run_cmd_and_expect(&cmd, "Result: SUCCESS")?;
}
Ok(())
}

View File

@ -0,0 +1,499 @@
# This test list is generated based on the Python 3.12.12 source.
# To regenerate this list, run the following commands:
# curl https://www.python.org/ftp/python/3.12.12/Python-3.12.12.tar.xz -o Python-3.12.12.tar.xz
# tar xf Python-3.12.12.tar.xz
# export PYTHONPATH=$PWD/Python-3.12.12/Lib
# python -m test --list-tests
test.test_asyncio.test_base_events -i test_create_server_stream_bittype
test.test_asyncio.test_buffered_proto
test.test_asyncio.test_context
test.test_asyncio.test_eager_task_factory
test.test_asyncio.test_events -i python -m test -u all -v test.test_asyncio.test_events -i test_ssl_connect_accepted_socket -i test_server_close -i test_get_event_loop_new_process -i test_get_loop -i test_create_server* -i test_create_ssl*
test.test_asyncio.test_futures
test.test_asyncio.test_futures2
test.test_asyncio.test_locks
test.test_asyncio.test_pep492
test.test_asyncio.test_proactor_events
test.test_asyncio.test_protocols
test.test_asyncio.test_queues
test.test_asyncio.test_runners
test.test_asyncio.test_selector_events
test.test_asyncio.test_sendfile
test.test_asyncio.test_server
test.test_asyncio.test_sock_lowlevel -i test_cancel_sock_accept -i test_sock_client_fail -i test_recvfrom -i test_recvfrom_into -i test_sendto_blocking
test.test_asyncio.test_ssl -i test_create_connection_memory_leak -i test_flush_before_shutdown -i test_create_connection_ssl* -i test_create_server_ssl* -i test_remote_shutdown_receives_trailing_data* -i test_start_tls* -i test_shutdown*
test.test_asyncio.test_sslproto -i test_create_connection_memory_leak -i test_create_connection_ssl_failed_certificate -i test_start_tls*
test.test_asyncio.test_staggered
test.test_asyncio.test_streams -i test_open_connection_happy_eyeball_refcycles -i test_open_connection_no_loop_ssl -i test_open_unix_connection_no_loop_ssl
test.test_asyncio.test_subprocess
test.test_asyncio.test_taskgroups
test.test_asyncio.test_tasks
test.test_asyncio.test_threads
test.test_asyncio.test_timeouts
test.test_asyncio.test_transports
test.test_asyncio.test_unix_events
test.test_asyncio.test_waitfor
test.test_asyncio.test_windows_events
test.test_asyncio.test_windows_utils
test.test_concurrent_futures.test_as_completed -i test_duplicate_futures -i test_future_times_out -i test_no_timeout -i tearDownModule
test.test_concurrent_futures.test_deadlock -i ProcessPoolForkserverExecutorDeadlockTest
test.test_concurrent_futures.test_future
test.test_concurrent_futures.test_init -i ProcessPoolForkserverFailingInitializerTest -i ProcessPoolForkserverInitializerTest -i tearDownModule
test.test_concurrent_futures.test_process_pool -i ProcessPoolForkserverProcessPoolExecutorTest
test.test_concurrent_futures.test_shutdown -i ProcessPoolForkserverProcessPoolShutdownTest -i test_interpreter_shutdown -i test_cancel_futures_wait_false -i test_hang_gh83386
test.test_concurrent_futures.test_thread_pool
test.test_concurrent_futures.test_wait -i ProcessPoolForkserverWaitTest -i tearDownModule
test.test_future_stmt.test_future
test.test_future_stmt.test_future_flags
test.test_future_stmt.test_future_multiple_features
test.test_future_stmt.test_future_multiple_imports
test.test_future_stmt.test_future_single_import
test.test_gdb.test_backtrace
test.test_gdb.test_cfunction
test.test_gdb.test_cfunction_full
test.test_gdb.test_misc
test.test_gdb.test_pretty_print
test.test_inspect.test_inspect -i test_details
test.test_multiprocessing_fork.test_manager
test.test_multiprocessing_fork.test_misc -i test_flags -i test_context -i test_set_get -i tearDownModule
test.test_multiprocessing_fork.test_processes
test.test_multiprocessing_fork.test_threads
# test.test_multiprocessing_forkserver.test_manager
test.test_multiprocessing_forkserver.test_misc -i test_closefd -i test_flags -i test_lock -i test_noforkbomb -i test_ignore* -i test_manager_initializer -i test_pool_initializer -i test_resource_tracker_reused -i test_empty -i test_context -i test_nested_startmethod -i test_preload_resources -i test_pool_in_process -i test_queue_in_process -i test_set_get -i TestSyncManagerTypes -i test_timeout -i test_neg_timeout -i test_wait* -i tearDownModule
# test.test_multiprocessing_forkserver.test_processes
test.test_multiprocessing_forkserver.test_threads -i test_rapid_restart
test.test_multiprocessing_spawn.test_manager -i test_map_no_failfast
test.test_multiprocessing_spawn.test_misc -i test_closefd -i test_flags -i test_empty -i test_context -i test_mixed_startmethod -i test_set_get -i test_wait_integer -i tearDownModule
test.test_multiprocessing_spawn.test_processes -i WithProcessesTestBarrier -i test_notify* -i test_wait* -i test_event -i test_repr_lock -i test_repr_rlock -i test_map_no_failfast -i test_child_fd_inflation -i test_process -i test_get -i test_put -i test_task_done
test.test_multiprocessing_spawn.test_threads
test.test_pydoc.test_pydoc
test___all__
test__locale
test__opcode
test__osx_support
test__xxinterpchannels
test__xxsubinterpreters
test_abc
test_abstract_numbers
test_aifc
test_argparse
test_array
test_asdl_parser
test_ast
test_asyncgen
test_atexit
test_audioop
test_audit
test_augassign
test_base64
test_baseexception
test_bdb
test_bigaddrspace
test_bigmem
test_binascii
test_binop
test_bisect
test_bool
test_buffer
test_bufio
test_builtin -i test_divmod -i test_input_tty_non_ascii*
test_bytes
test_bz2
test_c_locale_coercion
test_calendar
test_call
test_capi
# test_cext
test_cgi
test_cgitb
test_charmapcodec
test_class
test_clinic
test_cmath
test_cmd
test_cmd_line -i test_longexp -i test_relativedir_bug46421
test_cmd_line_script -i test_directory* -i test_issue8202* -i test_module_in_* -i test_package* -i test_script* -i test_zipfile*
test_code
test_code_module
test_codeccallbacks
test_codecencodings_cn
test_codecencodings_hk
test_codecencodings_iso2022
test_codecencodings_jp
test_codecencodings_kr
test_codecencodings_tw
test_codecmaps_cn
test_codecmaps_hk
test_codecmaps_jp
test_codecmaps_kr
test_codecmaps_tw
test_codecs
test_codeop
test_collections
# test_colorsys
test_compare
test_compile
test_compileall -i test_ddir_empty_multiple_workers -i test_ddir_multiple_workers -i test_workers
test_compiler_assemble
test_compiler_codegen
test_complex
test_configparser
test_contains
test_context
test_contextlib
test_contextlib_async
test_copy
test_copyreg
test_coroutines
# test_cppext
test_cprofile
test_crashers
# test_crypt
test_csv
test_ctypes -i test_simple -i test_longdouble* -i test_find_library_with*
test_curses
test_dataclasses
test_datetime
test_dbm
test_dbm_dumb
test_dbm_gnu
test_dbm_ndbm
test_decimal
test_decorators
test_defaultdict
test_deque
test_descr -i test_floats
test_descrtut
test_devpoll
test_dict
test_dict_version
test_dictcomps
test_dictviews
test_difflib
test_dis
test_doctest
test_docxmlrpc
test_dtrace
test_dynamic
test_dynamicclassattribute
test_eintr
test_email
test_embed -i test_set_config
test_ensurepip
test_enum
test_enumerate
test_eof
test_epoll
test_errno
test_except_star
test_exception_group
test_exception_hierarchy
test_exception_variations
test_exceptions
test_extcall
test_faulthandler
test_fcntl -i test_fcntl_*
test_file
test_file_eintr
test_filecmp
test_fileinput -i test_buffer_sizes -i test_inplace* -i test_nextfile_oserror_deleting_backup -i test_pathlike_file_inplace -i test_readline_os*
test_fileio -i testReadintoByteArray
# test_fileutils
test_finalization
# test_float
test_flufl
test_fnmatch
test_fork1
test_format
test_fractions -i testMixedIntegerDivision
test_frame
test_frozen
test_fstring
# test_ftplib
test_funcattrs
test_functools
test_gc
test_generator_stop
test_generators
test_genericalias
test_genericclass
test_genericpath
test_genexps
test_getopt
test_getpass
test_getpath
test_gettext
test_glob
test_global
test_grammar
test_graphlib
test_grp
test_gzip
test_hash
test_hashlib
test_heapq
test_hmac
test_html
test_htmlparser
test_http_cookiejar
test_http_cookies
test_httplib -i test_response_fileno -i HTTPSTest -i testHTTPConnectionSourceAddress
test_httpservers -i test_undecodable_filename
test_idle
# test_imaplib
test_imghdr
test_import -i test_unencodable_filename
test_importlib -i test_finder
test_index
test_int
test_int_literal
test_interpreters
test_io -i test_large_file_ops -i test_interrupted_write_unbuffered
test_ioctl
test_ipaddress
test_isinstance
test_iter
test_iterlen
test_itertools
test_json
test_keyword
test_keywordonlyarg
test_kqueue
# test_largefile
test_launcher
test_lib2to3
test_linecache
test_list
test_listcomps
test_lltrace
test_locale
test_logging -i test_output -i test_noserver -i test_max_bytes* -i test_namer_rotator_inheritance -i test_rollover*
test_long
test_longexp
test_lzma
test_mailbox -i test_nonempty* -i TestMaildir
test_mailcap
test_marshal
test_math -i testRemainder
test_math_property
test_memoryio
test_memoryview
test_metaclass
test_mimetypes
test_minidom
test_mmap
test_module -i test_module_finalization_at_shutdown
test_modulefinder
test_monitoring
test_msilib
test_multibytecodec
test_multiprocessing_main_handling -i ForkServerCmdLineTest
test_named_expressions
test_netrc
test_nis
test_nntplib -i test_starttls
# test_ntpath
test_numeric_tower
test_opcache
test_opcodes
test_openpty
test_operator
test_optparse
test_ordered_dict
test_os -i test_getcwd_long_path -i test_listdir -i test_remove_nothing -i test_blocking -i test_dup -i test_dup2 -i test_dup2_negative_fd -i test_fchdir -i test_fchmod -i test_fchown -i test_fdatasync -i test_fdopen -i test_fpathconf -i test_fstat -i test_fstatvfs -i test_fsync -i test_ftruncate -i test_inheritable -i test_lseek -i test_read -i test_readv -i test_remove_partial -i test_replace -i test_tcgetpgrp -i test_tcsetpgrpt -i test_ttyname -i test_walk_bad_dir -i test_write -i test_writev
test_ossaudiodev
test_osx_env
test_pathlib -i test_walk_bad_dir
test_patma
test_pdb -i test_basic_completion
test_peepholer
test_peg_generator
test_pep646_syntax
test_perf_profiler
test_perfmaps
test_pickle
test_picklebuffer
test_pickletools
test_pipes
test_pkg
test_pkgutil
test_platform
test_plistlib
test_poll
test_popen
# test_poplib
test_positional_only_arg
test_posix -i test_fchown -i test_lchown -i test_sched_rr_get_interval -i test_chown -i test_pipe2
# test_posixpath
test_pow
test_pprint
test_print
test_profile
test_property
test_pstats
test_pty
test_pulldom
test_pwd
test_py_compile
test_pyclbr
test_pyexpat
test_queue
test_quopri
test_raise
test_random
test_range
test_re
test_readline -i test_nonascii -i test_set_complete_delims
test_regrtest -i ArgsTestCase -i test_finds_expected_number_of_tests -i test_module*
test_repl
test_reprlib
test_resource
test_richcmp
test_rlcompleter
test_robotparser
test_runpy
test_sax
test_sched
test_scope
test_script_helper
test_secrets
test_select
test_selectors -i test_register_file
test_set
test_setcomps
test_shelve
test_shlex
test_shutil -i test_stty_match -i test_rmtree_errors* -i test_copyxattr_symlinks -i test_unpack_archive*
# test_signal -i test_itimer_prof -i test_itimer_virtual -i test_wakeup_fd_during -i test_wakeup_fd_early
test_site -i test_license_exists_at_url -i test_startup_imports
test_slice
test_smtplib
# test_smtpnet
test_sndhdr
test_socket -i testDetach -i BasicUDPLITETest -i BasicUDPTest -i testRecvFromIntoEmptyBuffer -i testCreateConnectionClose -i testSourceAddress -i NetworkConnectionNoServer -i test_injected_authentication_failure -i testCmsgTrunc* -i testRecvmsgPeek -i testRecvmsgTrunc -i testSendmsgDontWait -i SendmsgUDPLITETest -i testUnencodableAddr -i UDPLITETimeoutTest -i test_tcp4 -i testCloseException -i testInterfaceNameIndex -i testSendtoErrors -i testSockName -i test_socket_fileno -i RecvmsgIntoUDPLITETest -i RecvmsgUDPLITETest
test_socketserver
test_sort
test_source_encoding
test_spwd
test_sqlite3
# test_ssl
test_stable_abi_ctypes
test_startfile
test_stat
test_statistics
test_strftime
test_string
test_string_literals
test_stringprep
test_strptime
test_strtod
test_struct
test_structseq
test_subclassinit
test_subprocess -i test_pipesize_default -i test_pipesizes
test_sunau
test_sundry
test_super
test_support -i test_rmtree
test_symtable
# test_syntax
test_sys -i test_stdlib_dir
test_sys_setprofile
test_sys_settrace
test_sysconfig
test_syslog
test_tabnanny -i test_command_usage
test_tarfile -i test_extract_hardlink -i test_premature_end_of_archive -i test_fileobj_iter -i test_fileobj_readlines -i test_fileobj_seek -i test_sparse_file* -i test_deferred_directory_attributes_update -i TestExtractionFilters -i NoneInfoExtractTests_Data -i NoneInfoExtractTests_Tar
test_tcl
test_telnetlib
test_tempfile
test_termios -i test_tcdrain -i test_tcflow -i test_tcflush -i test_tcsendbreak -i test_tcflow_errors -i test_tcflush_errors
test_textwrap
test_thread
test_threadedtempfile
test_threading -i test_4_daemon_threads
test_threading_local
test_threadsignals
test_time -i test_pthread_getcpuclockid -i test_clock_settime -i test_get_clock_info -i test_monotonic_settime -i test_process_time -i test_thread_time -i test_clock_getres
test_timeit
test_timeout
test_tix
test_tkinter
test_tokenize
test_tomllib
test_tools -i test_freeze_simple_script
test_trace
test_traceback
test_tracemalloc
test_ttk
test_ttk_textonly
test_tty
test_tuple
test_turtle
test_type_aliases
test_type_annotations
test_type_cache
test_type_comments
test_type_params
test_typechecks
test_types
test_typing
test_ucn
test_unary
test_unicode
# test_unicode_file
test_unicode_file_functions
test_unicode_identifiers
test_unicodedata
test_unittest -i testSelectedTestNamesFunctionalTest
test_univnewlines
test_unpack
test_unpack_ex
test_unparse
test_urllib
test_urllib2
test_urllib2_localnet -i test_https*
test_urllib2net
test_urllib_response
test_urllibnet
test_urlparse
test_userdict
test_userlist
test_userstring
test_utf8_mode
test_utf8source
test_uu
test_uuid
test_venv -i test_zippath_from_non_installed_posix -i test_with_pip -i test_prefixes -i test_sysconfig*
test_wait3
test_wait4
test_warnings
test_wave
test_weakref -i test_atexit
test_weakset
test_webbrowser
test_winapi
test_winconsoleio
test_winreg
test_winsound
test_with
test_wmi
test_wsgiref
test_xdrlib
test_xml_dom_minicompat
test_xml_dom_xmlbuilder
test_xml_etree
test_xml_etree_c
test_xmlrpc
test_xmlrpc_net
test_xxlimited
test_xxtestfuzz
test_yield_from
test_zipapp
test_zipfile
# test_zipfile64
test_zipimport
test_zipimport_support
test_zlib
test_zoneinfo