Bug 34012 - check-plt.sh doesn't correctly detect the absence of readelf
Summary: check-plt.sh doesn't correctly detect the absence of readelf
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.10.2
Hardware: Other Solaris
: medium minor
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-07 16:51 UTC by Tim Mooney
Modified: 2011-03-16 16:23 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Option 1 (627 bytes, patch)
2011-03-15 16:04 UTC, Andrea Canciani
Details | Splinter Review
updated version of Andrea's patch, to exit 77 if the test will be skipped (1.83 KB, patch)
2011-03-16 15:27 UTC, Tim Mooney
Details | Splinter Review
updated patch that checks for presence and lineage of more tools (3.12 KB, patch)
2011-03-16 16:23 UTC, Tim Mooney
Details | Splinter Review

Description Tim Mooney 2011-02-07 16:51:15 UTC
x86_64-sun-solaris2.10, Solaris 10u6 (not OpenSolaris)

Although the src/check-plt.sh tries to detect whether readelf is available, it uses the "which" command to do so, and in so doing relies on the semantics of the Linux "which" command.  This will fail if "which" has been aliased to something else (like "builtin type -all" for bash), or if "which" is what POSIX systems typically have -- a csh shell script that only really works for people that use Csh.

There are a couple of options:

1) use "command -v", which is apparently what POSIX specifies instead of the "which" command.

2) Just try execute the command, and test the return value for 127, which is what it should be for "command not found":

    readelf /bin/sh >/dev/null 2>&1
    if test $? -eq 127 ; then
        :
    else
        echo "'readelf' not found; skipping test"
        exit 0
    fi

3) search the PATH for a readelf, and exit if none is found:

    OLD_IFS="$IFS"
    IFS=":"

    for d in $PATH
    do
        #echo "Checking $d for readelf..."
        if test -x $d/readelf ; then
           readelf=$d/readelf
            break;
        fi
    done
    IFS="$OLD_IFS"

    if test X"$readelf" != X""; then
        :
    else
        echo "'readelf' not found; skipping test"
        exit 0
    fi


I'll happily provide a patch for any of these, if you're willing to accept one of them as a suitable change.
Comment 1 Tim Mooney 2011-02-07 16:55:21 UTC
It looks like check-def.sh also depends on the Linux "which" semantics, so it should have the same change made to it.

It also depends on output formats and semantics from a few other commands, including objdump and c++filt, but I'll see if something can be done about that and report it separately if so.
Comment 2 Andrea Canciani 2011-03-15 16:04:15 UTC
Created attachment 44488 [details] [review]
Option 1

This is supposed to be an implementation of your first option.
I tested it on bash on both Ubuntu and MacOSX.

Can you confirm if this is what you had in mind and if it works as expected in your environment?

I like (1) better than the other options, because it keeps the scripts simple.
I'd like to defer complicating them as much as possible.
Comment 3 Tim Mooney 2011-03-16 14:44:26 UTC
Your patch works perfectly on my workstation (Solaris 10 x86_64):

'readelf' not found; skipping test
PASS: check-plt.sh

Thanks Andrea!
Comment 4 Behdad Esfahbod 2011-03-16 14:55:02 UTC
We probably should update all those check-*.sh tests to return 77 if test is skipped such that "make check" understands that the tests where skipped.
Comment 5 Tim Mooney 2011-03-16 15:26:01 UTC
I've updated check-def.sh, check-doc-syntax.sh, and check-plt.sh to use "exit 77" if they're going to skip, rather than exit 0.  None of the other src/check-* scripts have tests in place to skip if tools are missing or inappropriate, though some of them should.

Patch is attached.  I now get (for the src/ tests only):


/local/gnu/bin/gmake  check-TESTS
gmake[4]: Entering directory `/local/src/RPM/BUILD/cairo-1.10.2/src'
Checking that .libs/libcairo.so has the same symbol list as cairo.def
can't read file "--no-params"
2,330d1
< cairo_append_path
< cairo_arc
< cairo_arc_negative
< cairo_clip
< cairo_clip_extents
< cairo_clip_preserve
< cairo_close_path
< cairo_copy_clip_rectangle_list
< cairo_copy_page
< cairo_copy_path
< cairo_copy_path_flat
< cairo_create
< cairo_curve_to
< cairo_debug_reset_static_data
< cairo_destroy
< cairo_device_acquire
< cairo_device_destroy
< cairo_device_finish
< cairo_device_flush
< cairo_device_get_reference_count
< cairo_device_get_type
< cairo_device_get_user_data
< cairo_device_reference
< cairo_device_release
< cairo_device_set_user_data
< cairo_device_status
< cairo_device_to_user
< cairo_device_to_user_distance
< cairo_fill
< cairo_fill_extents
< cairo_fill_preserve
< cairo_font_extents
< cairo_font_face_destroy
< cairo_font_face_get_reference_count
< cairo_font_face_get_type
< cairo_font_face_get_user_data
< cairo_font_face_reference
< cairo_font_face_set_user_data
< cairo_font_face_status
< cairo_font_options_copy
< cairo_font_options_create
< cairo_font_options_destroy
< cairo_font_options_equal
< cairo_font_options_get_antialias
< cairo_font_options_get_hint_metrics
< cairo_font_options_get_hint_style
< cairo_font_options_get_subpixel_order
< cairo_font_options_hash
< cairo_font_options_merge
< cairo_font_options_set_antialias
< cairo_font_options_set_hint_metrics
< cairo_font_options_set_hint_style
< cairo_font_options_set_subpixel_order
< cairo_font_options_status
< cairo_format_stride_for_width
< cairo_ft_font_face_create_for_ft_face
< cairo_ft_font_face_create_for_pattern
< cairo_ft_font_options_substitute
< cairo_ft_scaled_font_lock_face
< cairo_ft_scaled_font_unlock_face
< cairo_get_antialias
< cairo_get_current_point
< cairo_get_dash
< cairo_get_dash_count
< cairo_get_fill_rule
< cairo_get_font_face
< cairo_get_font_matrix
< cairo_get_font_options
< cairo_get_group_target
< cairo_get_line_cap
< cairo_get_line_join
< cairo_get_line_width
< cairo_get_matrix
< cairo_get_miter_limit
< cairo_get_operator
< cairo_get_reference_count
< cairo_get_scaled_font
< cairo_get_source
< cairo_get_target
< cairo_get_tolerance
< cairo_get_user_data
< cairo_gl_surface_create
< cairo_gl_surface_create_for_texture
< cairo_gl_surface_create_for_window
< cairo_gl_surface_get_height
< cairo_gl_surface_get_width
< cairo_gl_surface_set_size
< cairo_gl_surface_swapbuffers
< cairo_glx_device_create
< cairo_glx_device_get_context
< cairo_glx_device_get_display
< cairo_glyph_allocate
< cairo_glyph_extents
< cairo_glyph_free
< cairo_glyph_path
< cairo_has_current_point
< cairo_identity_matrix
< cairo_image_surface_create
< cairo_image_surface_create_for_data
< cairo_image_surface_create_from_png
< cairo_image_surface_create_from_png_stream
< cairo_image_surface_get_data
< cairo_image_surface_get_format
< cairo_image_surface_get_height
< cairo_image_surface_get_stride
< cairo_image_surface_get_width
< cairo_in_clip
< cairo_in_fill
< cairo_in_stroke
< cairo_line_to
< cairo_mask
< cairo_mask_surface
< cairo_matrix_init
< cairo_matrix_init_identity
< cairo_matrix_init_rotate
< cairo_matrix_init_scale
< cairo_matrix_init_translate
< cairo_matrix_invert
< cairo_matrix_multiply
< cairo_matrix_rotate
< cairo_matrix_scale
< cairo_matrix_transform_distance
< cairo_matrix_transform_point
< cairo_matrix_translate
< cairo_move_to
< cairo_new_path
< cairo_new_sub_path
< cairo_paint
< cairo_paint_with_alpha
< cairo_path_destroy
< cairo_path_extents
< cairo_pattern_add_color_stop_rgb
< cairo_pattern_add_color_stop_rgba
< cairo_pattern_create_for_surface
< cairo_pattern_create_linear
< cairo_pattern_create_radial
< cairo_pattern_create_rgb
< cairo_pattern_create_rgba
< cairo_pattern_destroy
< cairo_pattern_get_color_stop_count
< cairo_pattern_get_color_stop_rgba
< cairo_pattern_get_extend
< cairo_pattern_get_filter
< cairo_pattern_get_linear_points
< cairo_pattern_get_matrix
< cairo_pattern_get_radial_circles
< cairo_pattern_get_reference_count
< cairo_pattern_get_rgba
< cairo_pattern_get_surface
< cairo_pattern_get_type
< cairo_pattern_get_user_data
< cairo_pattern_reference
< cairo_pattern_set_extend
< cairo_pattern_set_filter
< cairo_pattern_set_matrix
< cairo_pattern_set_user_data
< cairo_pattern_status
< cairo_pdf_get_versions
< cairo_pdf_surface_create
< cairo_pdf_surface_create_for_stream
< cairo_pdf_surface_restrict_to_version
< cairo_pdf_surface_set_size
< cairo_pdf_version_to_string
< cairo_pop_group
< cairo_pop_group_to_source
< cairo_ps_get_levels
< cairo_ps_level_to_string
< cairo_ps_surface_create
< cairo_ps_surface_create_for_stream
< cairo_ps_surface_dsc_begin_page_setup
< cairo_ps_surface_dsc_begin_setup
< cairo_ps_surface_dsc_comment
< cairo_ps_surface_get_eps
< cairo_ps_surface_restrict_to_level
< cairo_ps_surface_set_eps
< cairo_ps_surface_set_size
< cairo_push_group
< cairo_push_group_with_content
< cairo_recording_surface_create
< cairo_recording_surface_ink_extents
< cairo_rectangle
< cairo_rectangle_list_destroy
< cairo_reference
< cairo_region_contains_point
< cairo_region_contains_rectangle
< cairo_region_copy
< cairo_region_create
< cairo_region_create_rectangle
< cairo_region_create_rectangles
< cairo_region_destroy
< cairo_region_equal
< cairo_region_get_extents
< cairo_region_get_rectangle
< cairo_region_intersect
< cairo_region_intersect_rectangle
< cairo_region_is_empty
< cairo_region_num_rectangles
< cairo_region_reference
< cairo_region_status
< cairo_region_subtract
< cairo_region_subtract_rectangle
< cairo_region_translate
< cairo_region_union
< cairo_region_union_rectangle
< cairo_region_xor
< cairo_region_xor_rectangle
< cairo_rel_curve_to
< cairo_rel_line_to
< cairo_rel_move_to
< cairo_reset_clip
< cairo_restore
< cairo_rotate
< cairo_save
< cairo_scale
< cairo_scaled_font_create
< cairo_scaled_font_destroy
< cairo_scaled_font_extents
< cairo_scaled_font_get_ctm
< cairo_scaled_font_get_font_face
< cairo_scaled_font_get_font_matrix
< cairo_scaled_font_get_font_options
< cairo_scaled_font_get_reference_count
< cairo_scaled_font_get_scale_matrix
< cairo_scaled_font_get_type
< cairo_scaled_font_get_user_data
< cairo_scaled_font_glyph_extents
< cairo_scaled_font_reference
< cairo_scaled_font_set_user_data
< cairo_scaled_font_status
< cairo_scaled_font_text_extents
< cairo_scaled_font_text_to_glyphs
< cairo_select_font_face
< cairo_set_antialias
< cairo_set_dash
< cairo_set_fill_rule
< cairo_set_font_face
< cairo_set_font_matrix
< cairo_set_font_options
< cairo_set_font_size
< cairo_set_line_cap
< cairo_set_line_join
< cairo_set_line_width
< cairo_set_matrix
< cairo_set_miter_limit
< cairo_set_operator
< cairo_set_scaled_font
< cairo_set_source
< cairo_set_source_rgb
< cairo_set_source_rgba
< cairo_set_source_surface
< cairo_set_tolerance
< cairo_set_user_data
< cairo_show_glyphs
< cairo_show_page
< cairo_show_text
< cairo_show_text_glyphs
< cairo_status
< cairo_status_to_string
< cairo_stroke
< cairo_stroke_extents
< cairo_stroke_preserve
< cairo_surface_copy_page
< cairo_surface_create_for_rectangle
< cairo_surface_create_similar
< cairo_surface_destroy
< cairo_surface_finish
< cairo_surface_flush
< cairo_surface_get_content
< cairo_surface_get_device
< cairo_surface_get_device_offset
< cairo_surface_get_fallback_resolution
< cairo_surface_get_font_options
< cairo_surface_get_mime_data
< cairo_surface_get_reference_count
< cairo_surface_get_type
< cairo_surface_get_user_data
< cairo_surface_has_show_text_glyphs
< cairo_surface_mark_dirty
< cairo_surface_mark_dirty_rectangle
< cairo_surface_reference
< cairo_surface_set_device_offset
< cairo_surface_set_fallback_resolution
< cairo_surface_set_mime_data
< cairo_surface_set_user_data
< cairo_surface_show_page
< cairo_surface_status
< cairo_surface_write_to_png
< cairo_surface_write_to_png_stream
< cairo_svg_get_versions
< cairo_svg_surface_create
< cairo_svg_surface_create_for_stream
< cairo_svg_surface_restrict_to_version
< cairo_svg_version_to_string
< cairo_text_cluster_allocate
< cairo_text_cluster_free
< cairo_text_extents
< cairo_text_path
< cairo_toy_font_face_create
< cairo_toy_font_face_get_family
< cairo_toy_font_face_get_slant
< cairo_toy_font_face_get_weight
< cairo_transform
< cairo_translate
< cairo_user_font_face_create
< cairo_user_font_face_get_init_func
< cairo_user_font_face_get_render_glyph_func
< cairo_user_font_face_get_text_to_glyphs_func
< cairo_user_font_face_get_unicode_to_glyph_func
< cairo_user_font_face_set_init_func
< cairo_user_font_face_set_render_glyph_func
< cairo_user_font_face_set_text_to_glyphs_func
< cairo_user_font_face_set_unicode_to_glyph_func
< cairo_user_to_device
< cairo_user_to_device_distance
< cairo_version
< cairo_version_string
< cairo_xlib_surface_create
< cairo_xlib_surface_create_for_bitmap
< cairo_xlib_surface_create_with_xrender_format
< cairo_xlib_surface_get_depth
< cairo_xlib_surface_get_display
< cairo_xlib_surface_get_drawable
< cairo_xlib_surface_get_height
< cairo_xlib_surface_get_screen
< cairo_xlib_surface_get_visual
< cairo_xlib_surface_get_width
< cairo_xlib_surface_get_xrender_format
< cairo_xlib_surface_set_drawable
< cairo_xlib_surface_set_size
FAIL: check-def.sh
GNU grep not found; skipping test
SKIP: check-doc-syntax.sh
Checking public headers for missing cairo_public decorators
grep: illegal option -- B
Usage:  grep [-c|-l|-q] [-bhinsvwx] pattern_list [file ...]
        grep [-c|-l|-q] [-bhinsvwx] [-e pattern_list]... [-f pattern_file]... [file...]
        grep -E [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        grep -E [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]
        grep -F [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        grep -F [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]
PASS: check-headers.sh
'readelf' not found; skipping test
SKIP: check-plt.sh
Checking that public header files #include "cairo.h" first (or none)
Checking that private header files #include "some cairo header" first (or none)
Checking that source files #include "cairoint.h" first (or none)
glew/glew.c:#include <GL/glew.h>
Checking that there is no #include <cairo.*.h>
Checking that feature conditionals are used with #if only (not #ifdef)
FAIL: check-preprocessor-syntax.sh
Check linking to the just built cairo library
PASS: check-link
========================================================================
2 of 4 tests failed
(2 tests were not run)
Please report to http://bugs.freedesktop.org/enter_bug.cgi?product=cairo
========================================================================


If I can find some time, I'll try open up a new bug about the other failures.
They're mostly because of assumed GNU syntax or semantics (like with diff or c++filt).
Comment 6 Tim Mooney 2011-03-16 15:27:15 UTC
Created attachment 44523 [details] [review]
updated version of Andrea's patch, to exit 77 if the test will be skipped
Comment 7 Tim Mooney 2011-03-16 16:22:24 UTC
Ok, I went through all the check-*.sh scripts in src and added code to check for the presence and GNU lineage of the tools that currently require GNU syntax.

Could someone review and test the attached patch please?

I now get

/local/gnu/bin/gmake  check-TESTS
gmake[4]: Entering directory `/local/src/RPM/BUILD/cairo-1.10.2/src'
GNU diff not found; skipping test
SKIP: check-def.sh
GNU grep not found; skipping test
SKIP: check-doc-syntax.sh
GNU grep not found; skipping test
SKIP: check-headers.sh
'readelf' not found; skipping test
SKIP: check-plt.sh
Checking that public header files #include "cairo.h" first (or none)
Checking that private header files #include "some cairo header" first (or none)
Checking that source files #include "cairoint.h" first (or none)
glew/glew.c:#include <GL/glew.h>
Checking that there is no #include <cairo.*.h>
Checking that feature conditionals are used with #if only (not #ifdef)
FAIL: check-preprocessor-syntax.sh
Check linking to the just built cairo library
PASS: check-link
========================================================================
1 of 2 tests failed
(4 tests were not run)
Please report to http://bugs.freedesktop.org/enter_bug.cgi?product=cairo
========================================================================
Comment 8 Tim Mooney 2011-03-16 16:23:42 UTC
Created attachment 44525 [details] [review]
updated patch that checks for presence and lineage of more tools


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.