Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astring.strip_console_codes raises error on recent kernel messages #133

Open
smitterl opened this issue Aug 7, 2024 · 1 comment · May be fixed by #134
Open

astring.strip_console_codes raises error on recent kernel messages #133

smitterl opened this issue Aug 7, 2024 · 1 comment · May be fixed by #134

Comments

@smitterl
Copy link

smitterl commented Aug 7, 2024

Applying the strip_console_codes to the output of a recent (rescue) kernel "6.10.0-15" boot messages, a test error is raised:

ERROR: c is not included in the known console codes list %[G@8]|\[[@A-HJ-MPXa-hl-nqrsu\`]|\[[\d;]+[HJKgqnrm]|#8|\([B0UK]|\)|\[\?2004[lh]

The location that hits this is after the 'read-only' in

[    0.527428] systemd[1]: Successfully made /usr/ read-only.
^[c^[[!p^[]104^G^[[?7h[    0.527576] systemd[1]: systemd 256-11<cut> running in system mode (+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP -GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN -IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT -QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +XKBCOMMON +UTMP +SYSVINIT +LIBARCHIVE)

The tmp_word at this point is:

2024-08-07 09:57:07,684 astring          L0052 DEBUG| tmp_word: ^[
2024-08-07 09:57:07,684 astring          L0052 DEBUG| tmp_word: ^[c
2024-08-07 09:57:07,684 astring          L0052 DEBUG| tmp_word: ^[c^[
2024-08-07 09:57:07,684 astring          L0056 DEBUG| tmp_word: c

before it's recognized as unknown word.

IIUC "ESC c" is used to clear the console and in python this ESC is \x1b displayed as ^[. https://man7.org/linux/man-pages/man4/console_codes.4.html

smitterl added a commit to smitterl/aexpect that referenced this issue Aug 7, 2024
Fixes: avocado-framework#133

In recent kernel boots, stripping raised error because of missing
control characters.

Add them:
`c` is clear/reset screen
`!p` - don't know
`]104` - don't know

Signed-off-by: Sebastian Mitterle <[email protected]>
@smitterl smitterl linked a pull request Aug 7, 2024 that will close this issue
@smitterl
Copy link
Author

It looks to me the sequences are:

ESC c: terminal reset
ESC !p: terminal reset
ESC ]: introduces an OS command

I don't have details about the OS command 104.

Ref. https://gist.github.com/justinmk/a5102f9a0c1810437885a04a07ef0a91

smitterl added a commit to smitterl/aexpect that referenced this issue Aug 30, 2024
Fixes: avocado-framework#133

In recent kernel boots, stripping raised error because of missing
control characters.

Add them:
`c` reset screen
`!p` soft reset terminal
`]104` - execute OS command '104'

These control characters are listed in the xterm control sequence cheat
sheet at
https://gist.github.com/justinmk/a5102f9a0c1810437885a04a07ef0a91

Signed-off-by: Sebastian Mitterle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant