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

Unable to retrieve the value of crc32 command in uboot with exec0. #111

Closed
Adnan-Elhammoudi opened this issue Jan 30, 2024 · 2 comments · Fixed by #112
Closed

Unable to retrieve the value of crc32 command in uboot with exec0. #111

Adnan-Elhammoudi opened this issue Jan 30, 2024 · 2 comments · Fixed by #112
Labels
bad-behavior tbot incorrectly handles a certain situation. has-workaround This issue can temporarily be fixed by a hack/workaround

Comments

@Adnan-Elhammoudi
Copy link

Hi!

This assertion is failing because exec0 does not return the complete result, even though stdout does!
Could you please advise me on how to ensure that the entire result is returned?

            .
            .
            pattern = re.compile(r'=(\w+)')
            fileaddr =  pattern.findall(ub.env("fileaddr"))
            filesize =  pattern.findall(ub.env("filesize"))
            output = ub.exec0("crc32", f"{fileaddr[0]}" ,f"{filesize[0]}")
>           assert expected_crc in output
E           AssertionError: assert 'b2aff8d0' in '\ncrc32 for 80280000 ... 8028004b ='
│   ├─[device-u-boot] crc32 80280000 4c
│   │    ## 
│   │    ## crc32 for 80280000 ... 8028004b ==> b2aff8d0
@Rahix
Copy link
Owner

Rahix commented Jan 30, 2024

Hi,

yeah I have seen this exact problem in the past but never managed to build a proper solution for it... So what's happening is that the => inside the output of crc32 looks exactly like a U-Boot prompt to tbot. And that confuses the console parsing code...

I think a workaround that may help for the time being is to temporarily change the prompt matcher like this:

with ub.ch.with_prompt('\n=> '):
    ub.exec0("crc32", ...)

If this doesn't work, you could implement the one command by hand:

cmd = self.escape("crc32", f"{fileaddr[0]}" ,f"{filesize[0]}")
with tbot.log_event.command(self.name, cmd) as ev:
    self.ch.sendline(cmd + ";echo crcdone", read_back=True)
    with self.ch.with_stream(ev, show_prompt=False):
        out = self.ch.expect("crcdone")
        self.ch.sendline("true")
        self.ch.read_until_prompt()
    ev.data["stdout"] = out
output = out

Let me know how it goes...

@Rahix Rahix added has-workaround This issue can temporarily be fixed by a hack/workaround bad-behavior tbot incorrectly handles a certain situation. labels Jan 30, 2024
@Adnan-Elhammoudi
Copy link
Author

The workaround code snippet works for me!

with ub.ch.with_prompt('\n=> '):
    ub.exec0("crc32", ...)

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad-behavior tbot incorrectly handles a certain situation. has-workaround This issue can temporarily be fixed by a hack/workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants