Message ID | 20250115193917.8133-1-gavrosc@yahoo.com |
---|---|
State | New |
Headers | show |
Series | [v2] sanity: test for c toolchain | expand |
Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information: --- Testing patch /home/patchtest/share/mboxes/v2-sanity-test-for-c-toolchain.patch FAIL: test bugzilla entry format: Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]" (test_mbox.TestMbox.test_bugzilla_entry_format) PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence) PASS: test author valid (test_mbox.TestMbox.test_author_valid) PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence) PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags) PASS: test max line length (test_metadata.TestMetadata.test_max_line_length) PASS: test mbox format (test_mbox.TestMbox.test_mbox_format) PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade) PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format) PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length) PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list) SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint) SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files) SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore) SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format) SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence) SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format) SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned) SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence) SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence) SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint) SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head) SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files) SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence) --- Please address the issues identified and submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!
Hi Christos, This look like a solid v2 :) Le 15/01/2025 à 20:39, Christos Gavros via lists.openembedded.org a écrit : > Users reported issues caused by missing the right libstdc++-version-dev. > A new function 'check_c_toolchain' added in sanity.bbclass to test linking libstdc++ > Fixes [YOCTO #<15712>] Proper way to tag this bugzilla ticket is "Fixes [YOCTO #15712]" See https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html#implement-and-commit-changes (or any of the previous commits including this tag. Now, I notice that the patchtest message is a bit misleading. With the tag fixed, you can add my reviewed-by tag: Reviewed-by: Yoann Congal <yoann.congal@smile.fr> > Signed-off-by: Christos Gavros <gavrosc@yahoo.com> > --- > v1->v2 > * use shortlog > * drop the meta-oe prefix > * fix format for bug reference > * change function description including libstdc++ > * use BUILD_CC instead of specific compiler > * lines in comments are removed > * patch message less than 200 char > * bb.fatal is removed > * follow pattern of other functions in class > * use docstring instead of # in functions description > * make the print out message more clear > * fix comment style where the function is called > * change "hello world" from C++ to C program > * use gcc instead of g++ > --- > meta/classes-global/sanity.bbclass | 40 ++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass > index 7b8a497d5a..3a5a1f5d66 100644 > --- a/meta/classes-global/sanity.bbclass > +++ b/meta/classes-global/sanity.bbclass > @@ -780,6 +780,43 @@ def sanity_check_locale(d): > except locale.Error: > raise_sanity_error("Your system needs to support the en_US.UTF-8 locale.", d) > > +def check_c_toolchain(d): > + """ > + it checks if the c compiling and linking to libstdc++ works properly in the native system > + """ > + import os > + import subprocess > + from tempfile import NamedTemporaryFile > + > + try: > + with NamedTemporaryFile(delete=False, suffix=".c") as c_file: > + c_code = """ > + #include <stdio.h> > + int main() { > + printf(\"Hello, World!\\n\"); > + return 0; > + } > + """ > + c_file.write(c_code.encode('utf-8')) > + c_file_name = c_file.name > + > + build_cc = d.getVar('BUILD_CC').strip() > + output_binary = c_file_name + ".out" > + compile_command = [build_cc, c_file_name, '-o', output_binary,'-lstdc++'] > + result = subprocess.run(compile_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > + > + if result.returncode == 0: > + return None > + else: > + return f"C toolchain check failed to link against libstdc++. Please ensure libstdc++ and headers are installed. Error:\n{result.stderr.decode()}" > + except Exception as e: > + return f"An unexpected issue occurred during the C toolchain check: {str(e)}" > + finally: > + if c_file_name and os.path.exists(c_file_name): > + os.remove(c_file_name) > + if output_binary and os.path.exists(output_binary): > + os.remove(output_binary) > + > def check_sanity_everybuild(status, d): > import os, stat > # Sanity tests which test the users environment so need to run at each build (or are so cheap > @@ -976,6 +1013,9 @@ def check_sanity_everybuild(status, d): > if '/dash' not in real_sh and '/bash' not in real_sh: > status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh) > > + # Check if linking with lstdc++ is failing > + status.addresult(check_c_toolchain(d)) > + > def check_sanity(sanity_data): > class SanityStatus(object): > def __init__(self): > > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#209924): https://lists.openembedded.org/g/openembedded-core/message/209924 > Mute This Topic: https://lists.openembedded.org/mt/110634330/4316185 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [yoann.congal@smile.fr] > -=-=-=-=-=-=-=-=-=-=-=- >
Oops forgot something Le 15/01/2025 à 20:39, Christos Gavros via lists.openembedded.org a écrit : > Users reported issues caused by missing the right libstdc++-version-dev. > A new function 'check_c_toolchain' added in sanity.bbclass to test linking libstdc++ > Fixes [YOCTO #<15712>] > > Signed-off-by: Christos Gavros <gavrosc@yahoo.com> > --- > v1->v2 > * use shortlog > * drop the meta-oe prefix > * fix format for bug reference > * change function description including libstdc++ > * use BUILD_CC instead of specific compiler > * lines in comments are removed > * patch message less than 200 char > * bb.fatal is removed > * follow pattern of other functions in class > * use docstring instead of # in functions description > * make the print out message more clear > * fix comment style where the function is called > * change "hello world" from C++ to C program > * use gcc instead of g++ > --- > meta/classes-global/sanity.bbclass | 40 ++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass > index 7b8a497d5a..3a5a1f5d66 100644 > --- a/meta/classes-global/sanity.bbclass > +++ b/meta/classes-global/sanity.bbclass > @@ -780,6 +780,43 @@ def sanity_check_locale(d): > except locale.Error: > raise_sanity_error("Your system needs to support the en_US.UTF-8 locale.", d) > > +def check_c_toolchain(d): > + """ > + it checks if the c compiling and linking to libstdc++ works properly in the native system > + """ > + import os > + import subprocess > + from tempfile import NamedTemporaryFile > + ^^^^ I forgot to tell you that you have whitespaces here > + try: > + with NamedTemporaryFile(delete=False, suffix=".c") as c_file: > + c_code = """ > + #include <stdio.h> > + int main() { > + printf(\"Hello, World!\\n\"); > + return 0; > + } > + """ > + c_file.write(c_code.encode('utf-8')) > + c_file_name = c_file.name > + > + build_cc = d.getVar('BUILD_CC').strip() > + output_binary = c_file_name + ".out" > + compile_command = [build_cc, c_file_name, '-o', output_binary,'-lstdc++'] > + result = subprocess.run(compile_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > + > + if result.returncode == 0: > + return None > + else: > + return f"C toolchain check failed to link against libstdc++. Please ensure libstdc++ and headers are installed. Error:\n{result.stderr.decode()}" > + except Exception as e: > + return f"An unexpected issue occurred during the C toolchain check: {str(e)}" > + finally: > + if c_file_name and os.path.exists(c_file_name): > + os.remove(c_file_name) > + if output_binary and os.path.exists(output_binary): > + os.remove(output_binary) > + > def check_sanity_everybuild(status, d): > import os, stat > # Sanity tests which test the users environment so need to run at each build (or are so cheap > @@ -976,6 +1013,9 @@ def check_sanity_everybuild(status, d): > if '/dash' not in real_sh and '/bash' not in real_sh: > status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh) > > + # Check if linking with lstdc++ is failing and here ----------------------------------------^ > + status.addresult(check_c_toolchain(d)) > + > def check_sanity(sanity_data): > class SanityStatus(object): > def __init__(self): > > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#209924): https://lists.openembedded.org/g/openembedded-core/message/209924 > Mute This Topic: https://lists.openembedded.org/mt/110634330/4316185 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [yoann.congal@smile.fr] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass index 7b8a497d5a..3a5a1f5d66 100644 --- a/meta/classes-global/sanity.bbclass +++ b/meta/classes-global/sanity.bbclass @@ -780,6 +780,43 @@ def sanity_check_locale(d): except locale.Error: raise_sanity_error("Your system needs to support the en_US.UTF-8 locale.", d) +def check_c_toolchain(d): + """ + it checks if the c compiling and linking to libstdc++ works properly in the native system + """ + import os + import subprocess + from tempfile import NamedTemporaryFile + + try: + with NamedTemporaryFile(delete=False, suffix=".c") as c_file: + c_code = """ + #include <stdio.h> + int main() { + printf(\"Hello, World!\\n\"); + return 0; + } + """ + c_file.write(c_code.encode('utf-8')) + c_file_name = c_file.name + + build_cc = d.getVar('BUILD_CC').strip() + output_binary = c_file_name + ".out" + compile_command = [build_cc, c_file_name, '-o', output_binary,'-lstdc++'] + result = subprocess.run(compile_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + if result.returncode == 0: + return None + else: + return f"C toolchain check failed to link against libstdc++. Please ensure libstdc++ and headers are installed. Error:\n{result.stderr.decode()}" + except Exception as e: + return f"An unexpected issue occurred during the C toolchain check: {str(e)}" + finally: + if c_file_name and os.path.exists(c_file_name): + os.remove(c_file_name) + if output_binary and os.path.exists(output_binary): + os.remove(output_binary) + def check_sanity_everybuild(status, d): import os, stat # Sanity tests which test the users environment so need to run at each build (or are so cheap @@ -976,6 +1013,9 @@ def check_sanity_everybuild(status, d): if '/dash' not in real_sh and '/bash' not in real_sh: status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh) + # Check if linking with lstdc++ is failing + status.addresult(check_c_toolchain(d)) + def check_sanity(sanity_data): class SanityStatus(object): def __init__(self):
Users reported issues caused by missing the right libstdc++-version-dev. A new function 'check_c_toolchain' added in sanity.bbclass to test linking libstdc++ Fixes [YOCTO #<15712>] Signed-off-by: Christos Gavros <gavrosc@yahoo.com> --- v1->v2 * use shortlog * drop the meta-oe prefix * fix format for bug reference * change function description including libstdc++ * use BUILD_CC instead of specific compiler * lines in comments are removed * patch message less than 200 char * bb.fatal is removed * follow pattern of other functions in class * use docstring instead of # in functions description * make the print out message more clear * fix comment style where the function is called * change "hello world" from C++ to C program * use gcc instead of g++ --- meta/classes-global/sanity.bbclass | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)