@@ -58,7 +58,7 @@ test('linux - glibc family detected via ldd', async (t) => {
5858 isLinux : ( ) => true
5959 } ,
6060 './filesystem' : {
61- readFile : ( ) => Promise . resolve ( 'bunch-of-text GLIBC ' )
61+ readFile : ( ) => Promise . resolve ( '# This file is part of the GNU C Library. ' )
6262 }
6363 } ) ;
6464
@@ -74,7 +74,7 @@ test('linux - glibc familySync detected via ldd', async (t) => {
7474 isLinux : ( ) => true
7575 } ,
7676 './filesystem' : {
77- readFileSync : ( ) => 'bunch-of-text GLIBC '
77+ readFileSync : ( ) => '# The GNU C Library is free software; you can redistribute it and/or '
7878 }
7979 } ) ;
8080
@@ -488,6 +488,43 @@ test('linux - glibc version detected via filesystem', async (t) => {
488488 t . is ( await libc . version ( ) , '1.23' ) ;
489489} ) ;
490490
491+ test ( 'linux - glibc version detected via filesystem (libc)' , async ( t ) => {
492+ t . plan ( 1 ) ;
493+
494+ const out = '--vers | --versi | --versio | --version)\necho \'ldd (GNU libc) 2.39\'' ;
495+ const libc = proxyquire ( '../' , {
496+ './process' : {
497+ isLinux : ( ) => true
498+ } ,
499+ './filesystem' : {
500+ readFile : ( ) => Promise . resolve ( out )
501+ }
502+ } ) ;
503+
504+ t . is ( await libc . version ( ) , '2.39' ) ;
505+ } ) ;
506+
507+ test ( 'linux - libc version not detected via filesystem (void linux musl)' , async ( t ) => {
508+ t . plan ( 1 ) ;
509+
510+ const out = 'startlibc_startGNU AS 2.35.1' ;
511+ const libc = proxyquire ( '../' , {
512+ './process' : {
513+ isLinux : ( ) => true ,
514+ getReport : ( ) => ( { } )
515+ } ,
516+ './filesystem' : {
517+ readFile : ( ) => Promise . resolve ( out )
518+ } ,
519+ child_process : {
520+ exec : ( _c , cb ) => cb ( null , out ) ,
521+ execSync : ( ) => out
522+ }
523+ } ) ;
524+
525+ t . is ( await libc . version ( ) , null ) ;
526+ } ) ;
527+
491528test ( 'linux - glibc version detected via filesystemSync' , async ( t ) => {
492529 t . plan ( 1 ) ;
493530
@@ -504,6 +541,43 @@ test('linux - glibc version detected via filesystemSync', async (t) => {
504541 t . is ( libc . versionSync ( ) , '1.23' ) ;
505542} ) ;
506543
544+ test ( 'linux - glibc version detected via filesystemSync (libc)' , async ( t ) => {
545+ t . plan ( 1 ) ;
546+
547+ const out = '--vers | --versi | --versio | --version)\necho \'ldd (GNU libc) 2.39\'' ;
548+ const libc = proxyquire ( '../' , {
549+ './process' : {
550+ isLinux : ( ) => true
551+ } ,
552+ './filesystem' : {
553+ readFileSync : ( ) => out
554+ }
555+ } ) ;
556+
557+ t . is ( libc . versionSync ( ) , '2.39' ) ;
558+ } ) ;
559+
560+ test ( 'linux - libc version not detected via filesystemSync (void linux musl)' , ( t ) => {
561+ t . plan ( 1 ) ;
562+
563+ const out = 'startlibc_startGNU AS 2.35.1' ;
564+ const libc = proxyquire ( '../' , {
565+ './process' : {
566+ isLinux : ( ) => true ,
567+ getReport : ( ) => ( { } )
568+ } ,
569+ './filesystem' : {
570+ readFile : ( ) => Promise . resolve ( out )
571+ } ,
572+ child_process : {
573+ exec : ( _c , cb ) => cb ( null , out ) ,
574+ execSync : ( ) => out
575+ }
576+ } ) ;
577+
578+ t . is ( libc . versionSync ( ) , null ) ;
579+ } ) ;
580+
507581test ( 'linux - glibc version detected via child process' , async ( t ) => {
508582 t . plan ( 1 ) ;
509583
0 commit comments