diff mbox series

libgit: add ptest for libgit2

Message ID 20230206084401.2055798-1-haitao.liu@windriver.com
State New
Headers show
Series libgit: add ptest for libgit2 | expand

Commit Message

Liu, Haitao Feb. 6, 2023, 8:44 a.m. UTC
Add ptest for libgit2.
ALl test passed on a trial run and it took around 21m56s to execute so
added curl-ptest to PTESTS_SLOW.

Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 ...ests-add-CLAR_FIXTURES_DIR-for-ptest.patch | 54 +++++++++++++++++++
 .../recipes-support/libgit2/libgit2/run-ptest |  7 +++
 meta/recipes-support/libgit2/libgit2_1.5.0.bb | 18 ++++++-
 4 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch
 create mode 100644 meta/recipes-support/libgit2/libgit2/run-ptest

Comments

Alexander Kanavin Feb. 6, 2023, 8:49 a.m. UTC | #1
Did you use kvm? 21 minutes looks excessive, and I'm not sure we want
to lengthen the ptest by this much. libgit2 is not at the core of the
typical linux stack.

The added patch needs a better commit message. What does it add or
change and why? Why is it inappropriate for upstream submission?

Alex

On Mon, 6 Feb 2023 at 09:44, jason.lau <Haitao.Liu@windriver.com> wrote:
>
> Add ptest for libgit2.
> ALl test passed on a trial run and it took around 21m56s to execute so
> added curl-ptest to PTESTS_SLOW.
>
> Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> ---
>  .../distro/include/ptest-packagelists.inc     |  1 +
>  ...ests-add-CLAR_FIXTURES_DIR-for-ptest.patch | 54 +++++++++++++++++++
>  .../recipes-support/libgit2/libgit2/run-ptest |  7 +++
>  meta/recipes-support/libgit2/libgit2_1.5.0.bb | 18 ++++++-
>  4 files changed, 78 insertions(+), 2 deletions(-)
>  create mode 100644 meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch
>  create mode 100644 meta/recipes-support/libgit2/libgit2/run-ptest
>
> diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
> index 5422ecd378..9b88b58070 100644
> --- a/meta/conf/distro/include/ptest-packagelists.inc
> +++ b/meta/conf/distro/include/ptest-packagelists.inc
> @@ -104,6 +104,7 @@ PTESTS_SLOW = "\
>      tcl-ptest \
>      util-linux-ptest \
>      valgrind-ptest \
> +    libgit2-ptest \
>  "
>
>  PTESTS_SLOW:remove:riscv64 = "valgrind-ptest"
> diff --git a/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch
> new file mode 100644
> index 0000000000..f547d29e8a
> --- /dev/null
> +++ b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch
> @@ -0,0 +1,54 @@
> +From 7ae59e785260bb820cf1449da84140f8ae613e9f Mon Sep 17 00:00:00 2001
> +From: Liu Haitao <haitao.liu@windriver.com>
> +Date: Mon, 6 Feb 2023 06:40:20 +0200
> +Subject: [PATCH] tests: add CLAR_FIXTURES_DIR for ptest
> +
> +Upstream-Status: Inappropriate [yocto specific]
> +
> +Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> +---
> + tests/libgit2/CMakeLists.txt | 8 +++++++-
> + tests/util/CMakeLists.txt    | 8 +++++++-
> + 2 files changed, 14 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/libgit2/CMakeLists.txt b/tests/libgit2/CMakeLists.txt
> +index 27f421ad6..e1a95a610 100644
> +--- a/tests/libgit2/CMakeLists.txt
> ++++ b/tests/libgit2/CMakeLists.txt
> +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> + ENDIF()
> +
> + set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
> +-set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> ++
> ++IF (CLAR_FIXTURES_DIR)
> ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> ++ELSE()
> ++      set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> ++ENDIF()
> ++
> + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> +diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
> +index 232590ffd..c736bb3bb 100644
> +--- a/tests/util/CMakeLists.txt
> ++++ b/tests/util/CMakeLists.txt
> +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> + ENDIF()
> +
> + set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
> +-set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> ++
> ++IF (CLAR_FIXTURES_DIR)
> ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> ++ELSE()
> ++      set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> ++ENDIF()
> ++
> + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> +--
> +2.39.1
> +
> diff --git a/meta/recipes-support/libgit2/libgit2/run-ptest b/meta/recipes-support/libgit2/libgit2/run-ptest
> new file mode 100644
> index 0000000000..66e0392af6
> --- /dev/null
> +++ b/meta/recipes-support/libgit2/libgit2/run-ptest
> @@ -0,0 +1,7 @@
> +#!/bin/sh
> +
> +cd tests
> +
> +export CLAR_SUMMARY="${PWD}/results.xml"
> +
> +./libgit2_tests -t | sed -e 's|ok .* - # SKIP|SKIP:|' -e 's|not ok .* -|FAIL:|'  -e 's|ok .* -|PASS:|'
> diff --git a/meta/recipes-support/libgit2/libgit2_1.5.0.bb b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> index ee4d79b11a..aca8b94551 100644
> --- a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> +++ b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> @@ -5,12 +5,15 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=112e6bb421dea73cd41de09e777f2d2c"
>
>  DEPENDS = "curl openssl zlib libssh2 libgcrypt libpcre2"
>
> -SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https"
> +SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https \
> +           file://0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch \
> +           file://run-ptest \
> +          "
>  SRCREV = "fbea439d4b6fc91c6b619d01b85ab3b7746e4c19"
>
>  S = "${WORKDIR}/git"
>
> -inherit cmake
> +inherit cmake ptest
>
>  EXTRA_OECMAKE = "\
>      -DBUILD_CLAR=OFF \
> @@ -19,4 +22,15 @@ EXTRA_OECMAKE = "\
>      -DREGEX_BACKEND='pcre2' \
>  "
>
> +EXTRA_OECMAKE_PTEST = " -DBUILD_CLAR=ON -DVALGRIND=ON -DCLAR_FIXTURES_DIR=${PTEST_PATH}/tests "
> +
> +EXTRA_OECMAKE += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '${EXTRA_OECMAKE_PTEST}', '', d)} "
> +
> +do_install_ptest(){
> +        install -d ${D}${PTEST_PATH}/tests/
> +        install ${B}/libgit2_tests ${D}${PTEST_PATH}/tests/
> +        cp ${S}/tests/resources/ ${D}${PTEST_PATH}/tests/ -rf
> +}
> +
> +
>  BBCLASSEXTEND = "native"
> --
> 2.39.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#176788): https://lists.openembedded.org/g/openembedded-core/message/176788
> Mute This Topic: https://lists.openembedded.org/mt/96779266/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Liu, Haitao Feb. 6, 2023, 9:43 a.m. UTC | #2
HI Alex

>// Did you use kvm? 21 minutes looks excessive, and I'm not sure we want to lengthen the ptest by this much. libgit2 is not at the core of the typical linux stack.

I have tested libgit2 on a intel board with "Intel(R) Genuine Intel(R) CPU", not KVM. It took so much time because that it has 2885 testcases. 

>// The added patch needs a better commit message. What does it add or change and why? Why is it inappropriate for upstream submission?

An absolute path (CLAR_FIXTURES)is defined as specifying the location of the resource files. The CLAR_FIXTURES is set at compile time.  
The test binary will try to load the files from the absolute patch which does not exist on target board and  it  yields a lot of errors about "No such file or directory. " 
So I  have to change CLAR_FIXTURES to PTEST path (/usr/lib/libgit2/ptest/). 


Thanks,
haitao

-----Original Message-----
From: Alexander Kanavin <alex.kanavin@gmail.com> 
Sent: Monday, February 6, 2023 4:49 PM
To: Liu, Haitao <Haitao.Liu@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][PATCH] libgit: add ptest for libgit2

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Did you use kvm? 21 minutes looks excessive, and I'm not sure we want to lengthen the ptest by this much. libgit2 is not at the core of the typical linux stack.

The added patch needs a better commit message. What does it add or change and why? Why is it inappropriate for upstream submission?

Alex

On Mon, 6 Feb 2023 at 09:44, jason.lau <Haitao.Liu@windriver.com> wrote:
>
> Add ptest for libgit2.
> ALl test passed on a trial run and it took around 21m56s to execute so 
> added curl-ptest to PTESTS_SLOW.
>
> Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> ---
>  .../distro/include/ptest-packagelists.inc     |  1 +
>  ...ests-add-CLAR_FIXTURES_DIR-for-ptest.patch | 54 
> +++++++++++++++++++  .../recipes-support/libgit2/libgit2/run-ptest |  
> 7 +++  meta/recipes-support/libgit2/libgit2_1.5.0.bb | 18 ++++++-
>  4 files changed, 78 insertions(+), 2 deletions(-)  create mode 100644 
> meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-
> for-ptest.patch  create mode 100644 
> meta/recipes-support/libgit2/libgit2/run-ptest
>
> diff --git a/meta/conf/distro/include/ptest-packagelists.inc 
> b/meta/conf/distro/include/ptest-packagelists.inc
> index 5422ecd378..9b88b58070 100644
> --- a/meta/conf/distro/include/ptest-packagelists.inc
> +++ b/meta/conf/distro/include/ptest-packagelists.inc
> @@ -104,6 +104,7 @@ PTESTS_SLOW = "\
>      tcl-ptest \
>      util-linux-ptest \
>      valgrind-ptest \
> +    libgit2-ptest \
>  "
>
>  PTESTS_SLOW:remove:riscv64 = "valgrind-ptest"
> diff --git 
> a/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DI
> R-for-ptest.patch 
> b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DI
> R-for-ptest.patch
> new file mode 100644
> index 0000000000..f547d29e8a
> --- /dev/null
> +++ b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURE
> +++ S_DIR-for-ptest.patch
> @@ -0,0 +1,54 @@
> +From 7ae59e785260bb820cf1449da84140f8ae613e9f Mon Sep 17 00:00:00 
> +2001
> +From: Liu Haitao <haitao.liu@windriver.com>
> +Date: Mon, 6 Feb 2023 06:40:20 +0200
> +Subject: [PATCH] tests: add CLAR_FIXTURES_DIR for ptest
> +
> +Upstream-Status: Inappropriate [yocto specific]
> +
> +Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> +---
> + tests/libgit2/CMakeLists.txt | 8 +++++++-
> + tests/util/CMakeLists.txt    | 8 +++++++-
> + 2 files changed, 14 insertions(+), 2 deletions(-)
> +
> +diff --git a/tests/libgit2/CMakeLists.txt 
> +b/tests/libgit2/CMakeLists.txt index 27f421ad6..e1a95a610 100644
> +--- a/tests/libgit2/CMakeLists.txt
> ++++ b/tests/libgit2/CMakeLists.txt
> +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> + ENDIF()
> +
> + set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
> +-set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> ++
> ++IF (CLAR_FIXTURES_DIR)
> ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> ++ELSE()
> ++      set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> ++ENDIF()
> ++
> + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> +diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt 
> +index 232590ffd..c736bb3bb 100644
> +--- a/tests/util/CMakeLists.txt
> ++++ b/tests/util/CMakeLists.txt
> +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> + ENDIF()
> +
> + set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
> +-set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> ++
> ++IF (CLAR_FIXTURES_DIR)
> ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> ++ELSE()
> ++      set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> ++ENDIF()
> ++
> + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> +--
> +2.39.1
> +
> diff --git a/meta/recipes-support/libgit2/libgit2/run-ptest 
> b/meta/recipes-support/libgit2/libgit2/run-ptest
> new file mode 100644
> index 0000000000..66e0392af6
> --- /dev/null
> +++ b/meta/recipes-support/libgit2/libgit2/run-ptest
> @@ -0,0 +1,7 @@
> +#!/bin/sh
> +
> +cd tests
> +
> +export CLAR_SUMMARY="${PWD}/results.xml"
> +
> +./libgit2_tests -t | sed -e 's|ok .* - # SKIP|SKIP:|' -e 's|not ok .* -|FAIL:|'  -e 's|ok .* -|PASS:|'
> diff --git a/meta/recipes-support/libgit2/libgit2_1.5.0.bb 
> b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> index ee4d79b11a..aca8b94551 100644
> --- a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> +++ b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> @@ -5,12 +5,15 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=112e6bb421dea73cd41de09e777f2d2c"
>
>  DEPENDS = "curl openssl zlib libssh2 libgcrypt libpcre2"
>
> -SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https"
> +SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https \
> +           file://0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch \
> +           file://run-ptest \
> +          "
>  SRCREV = "fbea439d4b6fc91c6b619d01b85ab3b7746e4c19"
>
>  S = "${WORKDIR}/git"
>
> -inherit cmake
> +inherit cmake ptest
>
>  EXTRA_OECMAKE = "\
>      -DBUILD_CLAR=OFF \
> @@ -19,4 +22,15 @@ EXTRA_OECMAKE = "\
>      -DREGEX_BACKEND='pcre2' \
>  "
>
> +EXTRA_OECMAKE_PTEST = " -DBUILD_CLAR=ON -DVALGRIND=ON -DCLAR_FIXTURES_DIR=${PTEST_PATH}/tests "
> +
> +EXTRA_OECMAKE += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '${EXTRA_OECMAKE_PTEST}', '', d)} "
> +
> +do_install_ptest(){
> +        install -d ${D}${PTEST_PATH}/tests/
> +        install ${B}/libgit2_tests ${D}${PTEST_PATH}/tests/
> +        cp ${S}/tests/resources/ ${D}${PTEST_PATH}/tests/ -rf }
> +
> +
>  BBCLASSEXTEND = "native"
> --
> 2.39.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#176788): 
> https://lists.openembedded.org/g/openembedded-core/message/176788
> Mute This Topic: https://lists.openembedded.org/mt/96779266/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
> [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexander Kanavin Feb. 6, 2023, 9:55 a.m. UTC | #3
Thanks, can you add this to the the patch description? Is it possible
to add the installation rules into it as well, and then offer the
patch upstream?

It's probably time we split slow ptests into subsets and test them in
parallel with two different image recipes. Can you look into that
please?

Alex


On Mon, 6 Feb 2023 at 10:43, Liu, Haitao <Haitao.Liu@windriver.com> wrote:
>
> HI Alex
>
> >// Did you use kvm? 21 minutes looks excessive, and I'm not sure we want to lengthen the ptest by this much. libgit2 is not at the core of the typical linux stack.
>
> I have tested libgit2 on a intel board with "Intel(R) Genuine Intel(R) CPU", not KVM. It took so much time because that it has 2885 testcases.
>
> >// The added patch needs a better commit message. What does it add or change and why? Why is it inappropriate for upstream submission?
>
> An absolute path (CLAR_FIXTURES)is defined as specifying the location of the resource files. The CLAR_FIXTURES is set at compile time.
> The test binary will try to load the files from the absolute patch which does not exist on target board and  it  yields a lot of errors about "No such file or directory. "
> So I  have to change CLAR_FIXTURES to PTEST path (/usr/lib/libgit2/ptest/).
>
>
> Thanks,
> haitao
>
> -----Original Message-----
> From: Alexander Kanavin <alex.kanavin@gmail.com>
> Sent: Monday, February 6, 2023 4:49 PM
> To: Liu, Haitao <Haitao.Liu@windriver.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core][PATCH] libgit: add ptest for libgit2
>
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> Did you use kvm? 21 minutes looks excessive, and I'm not sure we want to lengthen the ptest by this much. libgit2 is not at the core of the typical linux stack.
>
> The added patch needs a better commit message. What does it add or change and why? Why is it inappropriate for upstream submission?
>
> Alex
>
> On Mon, 6 Feb 2023 at 09:44, jason.lau <Haitao.Liu@windriver.com> wrote:
> >
> > Add ptest for libgit2.
> > ALl test passed on a trial run and it took around 21m56s to execute so
> > added curl-ptest to PTESTS_SLOW.
> >
> > Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> > ---
> >  .../distro/include/ptest-packagelists.inc     |  1 +
> >  ...ests-add-CLAR_FIXTURES_DIR-for-ptest.patch | 54
> > +++++++++++++++++++  .../recipes-support/libgit2/libgit2/run-ptest |
> > 7 +++  meta/recipes-support/libgit2/libgit2_1.5.0.bb | 18 ++++++-
> >  4 files changed, 78 insertions(+), 2 deletions(-)  create mode 100644
> > meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-
> > for-ptest.patch  create mode 100644
> > meta/recipes-support/libgit2/libgit2/run-ptest
> >
> > diff --git a/meta/conf/distro/include/ptest-packagelists.inc
> > b/meta/conf/distro/include/ptest-packagelists.inc
> > index 5422ecd378..9b88b58070 100644
> > --- a/meta/conf/distro/include/ptest-packagelists.inc
> > +++ b/meta/conf/distro/include/ptest-packagelists.inc
> > @@ -104,6 +104,7 @@ PTESTS_SLOW = "\
> >      tcl-ptest \
> >      util-linux-ptest \
> >      valgrind-ptest \
> > +    libgit2-ptest \
> >  "
> >
> >  PTESTS_SLOW:remove:riscv64 = "valgrind-ptest"
> > diff --git
> > a/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DI
> > R-for-ptest.patch
> > b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DI
> > R-for-ptest.patch
> > new file mode 100644
> > index 0000000000..f547d29e8a
> > --- /dev/null
> > +++ b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURE
> > +++ S_DIR-for-ptest.patch
> > @@ -0,0 +1,54 @@
> > +From 7ae59e785260bb820cf1449da84140f8ae613e9f Mon Sep 17 00:00:00
> > +2001
> > +From: Liu Haitao <haitao.liu@windriver.com>
> > +Date: Mon, 6 Feb 2023 06:40:20 +0200
> > +Subject: [PATCH] tests: add CLAR_FIXTURES_DIR for ptest
> > +
> > +Upstream-Status: Inappropriate [yocto specific]
> > +
> > +Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> > +---
> > + tests/libgit2/CMakeLists.txt | 8 +++++++-
> > + tests/util/CMakeLists.txt    | 8 +++++++-
> > + 2 files changed, 14 insertions(+), 2 deletions(-)
> > +
> > +diff --git a/tests/libgit2/CMakeLists.txt
> > +b/tests/libgit2/CMakeLists.txt index 27f421ad6..e1a95a610 100644
> > +--- a/tests/libgit2/CMakeLists.txt
> > ++++ b/tests/libgit2/CMakeLists.txt
> > +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> > + ENDIF()
> > +
> > + set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
> > +-set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> > ++
> > ++IF (CLAR_FIXTURES_DIR)
> > ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> > ++ELSE()
> > ++      set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> > ++ENDIF()
> > ++
> > + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> > + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> > + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> > +diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
> > +index 232590ffd..c736bb3bb 100644
> > +--- a/tests/util/CMakeLists.txt
> > ++++ b/tests/util/CMakeLists.txt
> > +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> > + ENDIF()
> > +
> > + set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
> > +-set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> > ++
> > ++IF (CLAR_FIXTURES_DIR)
> > ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> > ++ELSE()
> > ++      set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> > ++ENDIF()
> > ++
> > + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> > + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> > + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> > +--
> > +2.39.1
> > +
> > diff --git a/meta/recipes-support/libgit2/libgit2/run-ptest
> > b/meta/recipes-support/libgit2/libgit2/run-ptest
> > new file mode 100644
> > index 0000000000..66e0392af6
> > --- /dev/null
> > +++ b/meta/recipes-support/libgit2/libgit2/run-ptest
> > @@ -0,0 +1,7 @@
> > +#!/bin/sh
> > +
> > +cd tests
> > +
> > +export CLAR_SUMMARY="${PWD}/results.xml"
> > +
> > +./libgit2_tests -t | sed -e 's|ok .* - # SKIP|SKIP:|' -e 's|not ok .* -|FAIL:|'  -e 's|ok .* -|PASS:|'
> > diff --git a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > index ee4d79b11a..aca8b94551 100644
> > --- a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > +++ b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > @@ -5,12 +5,15 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=112e6bb421dea73cd41de09e777f2d2c"
> >
> >  DEPENDS = "curl openssl zlib libssh2 libgcrypt libpcre2"
> >
> > -SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https"
> > +SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https \
> > +           file://0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch \
> > +           file://run-ptest \
> > +          "
> >  SRCREV = "fbea439d4b6fc91c6b619d01b85ab3b7746e4c19"
> >
> >  S = "${WORKDIR}/git"
> >
> > -inherit cmake
> > +inherit cmake ptest
> >
> >  EXTRA_OECMAKE = "\
> >      -DBUILD_CLAR=OFF \
> > @@ -19,4 +22,15 @@ EXTRA_OECMAKE = "\
> >      -DREGEX_BACKEND='pcre2' \
> >  "
> >
> > +EXTRA_OECMAKE_PTEST = " -DBUILD_CLAR=ON -DVALGRIND=ON -DCLAR_FIXTURES_DIR=${PTEST_PATH}/tests "
> > +
> > +EXTRA_OECMAKE += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '${EXTRA_OECMAKE_PTEST}', '', d)} "
> > +
> > +do_install_ptest(){
> > +        install -d ${D}${PTEST_PATH}/tests/
> > +        install ${B}/libgit2_tests ${D}${PTEST_PATH}/tests/
> > +        cp ${S}/tests/resources/ ${D}${PTEST_PATH}/tests/ -rf }
> > +
> > +
> >  BBCLASSEXTEND = "native"
> > --
> > 2.39.0
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#176788):
> > https://lists.openembedded.org/g/openembedded-core/message/176788
> > Mute This Topic: https://lists.openembedded.org/mt/96779266/1686489
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
> > [alex.kanavin@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Liu, Haitao Feb. 6, 2023, 10:20 a.m. UTC | #4
Hi Alex,

>//Thanks, can you add this to the the patch description? Is it possible to add the installation rules into it as well, and then offer the patch upstream?
I thinks you are right, I should try to send the patch the libgit2 upstream first.

>// It's probably time we split slow ptests into subsets and test them in parallel with two different image recipes. Can you look into that please?

No problem, I could do it. it's my great honor.

Thanks,
haitao

-----Original Message-----
From: Alexander Kanavin <alex.kanavin@gmail.com> 
Sent: Monday, February 6, 2023 5:55 PM
To: Liu, Haitao <Haitao.Liu@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][PATCH] libgit: add ptest for libgit2

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Thanks, can you add this to the the patch description? Is it possible to add the installation rules into it as well, and then offer the patch upstream?

It's probably time we split slow ptests into subsets and test them in parallel with two different image recipes. Can you look into that please?

Alex


On Mon, 6 Feb 2023 at 10:43, Liu, Haitao <Haitao.Liu@windriver.com> wrote:
>
> HI Alex
>
> >// Did you use kvm? 21 minutes looks excessive, and I'm not sure we want to lengthen the ptest by this much. libgit2 is not at the core of the typical linux stack.
>
> I have tested libgit2 on a intel board with "Intel(R) Genuine Intel(R) CPU", not KVM. It took so much time because that it has 2885 testcases.
>
> >// The added patch needs a better commit message. What does it add or change and why? Why is it inappropriate for upstream submission?
>
> An absolute path (CLAR_FIXTURES)is defined as specifying the location of the resource files. The CLAR_FIXTURES is set at compile time.
> The test binary will try to load the files from the absolute patch which does not exist on target board and  it  yields a lot of errors about "No such file or directory. "
> So I  have to change CLAR_FIXTURES to PTEST path (/usr/lib/libgit2/ptest/).
>
>
> Thanks,
> haitao
>
> -----Original Message-----
> From: Alexander Kanavin <alex.kanavin@gmail.com>
> Sent: Monday, February 6, 2023 4:49 PM
> To: Liu, Haitao <Haitao.Liu@windriver.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core][PATCH] libgit: add ptest for libgit2
>
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> Did you use kvm? 21 minutes looks excessive, and I'm not sure we want to lengthen the ptest by this much. libgit2 is not at the core of the typical linux stack.
>
> The added patch needs a better commit message. What does it add or change and why? Why is it inappropriate for upstream submission?
>
> Alex
>
> On Mon, 6 Feb 2023 at 09:44, jason.lau <Haitao.Liu@windriver.com> wrote:
> >
> > Add ptest for libgit2.
> > ALl test passed on a trial run and it took around 21m56s to execute 
> > so added curl-ptest to PTESTS_SLOW.
> >
> > Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> > ---
> >  .../distro/include/ptest-packagelists.inc     |  1 +
> >  ...ests-add-CLAR_FIXTURES_DIR-for-ptest.patch | 54
> > +++++++++++++++++++  .../recipes-support/libgit2/libgit2/run-ptest |
> > 7 +++  meta/recipes-support/libgit2/libgit2_1.5.0.bb | 18 ++++++-
> >  4 files changed, 78 insertions(+), 2 deletions(-)  create mode 
> > 100644
> > meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DI
> > R-
> > for-ptest.patch  create mode 100644
> > meta/recipes-support/libgit2/libgit2/run-ptest
> >
> > diff --git a/meta/conf/distro/include/ptest-packagelists.inc
> > b/meta/conf/distro/include/ptest-packagelists.inc
> > index 5422ecd378..9b88b58070 100644
> > --- a/meta/conf/distro/include/ptest-packagelists.inc
> > +++ b/meta/conf/distro/include/ptest-packagelists.inc
> > @@ -104,6 +104,7 @@ PTESTS_SLOW = "\
> >      tcl-ptest \
> >      util-linux-ptest \
> >      valgrind-ptest \
> > +    libgit2-ptest \
> >  "
> >
> >  PTESTS_SLOW:remove:riscv64 = "valgrind-ptest"
> > diff --git
> > a/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_
> > DI
> > R-for-ptest.patch
> > b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_
> > DI
> > R-for-ptest.patch
> > new file mode 100644
> > index 0000000000..f547d29e8a
> > --- /dev/null
> > +++ b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTU
> > +++ RE
> > +++ S_DIR-for-ptest.patch
> > @@ -0,0 +1,54 @@
> > +From 7ae59e785260bb820cf1449da84140f8ae613e9f Mon Sep 17 00:00:00
> > +2001
> > +From: Liu Haitao <haitao.liu@windriver.com>
> > +Date: Mon, 6 Feb 2023 06:40:20 +0200
> > +Subject: [PATCH] tests: add CLAR_FIXTURES_DIR for ptest
> > +
> > +Upstream-Status: Inappropriate [yocto specific]
> > +
> > +Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
> > +---
> > + tests/libgit2/CMakeLists.txt | 8 +++++++-
> > + tests/util/CMakeLists.txt    | 8 +++++++-
> > + 2 files changed, 14 insertions(+), 2 deletions(-)
> > +
> > +diff --git a/tests/libgit2/CMakeLists.txt 
> > +b/tests/libgit2/CMakeLists.txt index 27f421ad6..e1a95a610 100644
> > +--- a/tests/libgit2/CMakeLists.txt
> > ++++ b/tests/libgit2/CMakeLists.txt
> > +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> > + ENDIF()
> > +
> > + set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
> > +-set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> > ++
> > ++IF (CLAR_FIXTURES_DIR)
> > ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> > ++ELSE()
> > ++      set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
> > ++ENDIF()
> > ++
> > + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> > + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> > + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> > +diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt 
> > +index 232590ffd..c736bb3bb 100644
> > +--- a/tests/util/CMakeLists.txt
> > ++++ b/tests/util/CMakeLists.txt
> > +@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
> > + ENDIF()
> > +
> > + set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
> > +-set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> > ++
> > ++IF (CLAR_FIXTURES_DIR)
> > ++      SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
> > ++ELSE()
> > ++      set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
> > ++ENDIF()
> > ++
> > + set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
> > + add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
> > + add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
> > +--
> > +2.39.1
> > +
> > diff --git a/meta/recipes-support/libgit2/libgit2/run-ptest
> > b/meta/recipes-support/libgit2/libgit2/run-ptest
> > new file mode 100644
> > index 0000000000..66e0392af6
> > --- /dev/null
> > +++ b/meta/recipes-support/libgit2/libgit2/run-ptest
> > @@ -0,0 +1,7 @@
> > +#!/bin/sh
> > +
> > +cd tests
> > +
> > +export CLAR_SUMMARY="${PWD}/results.xml"
> > +
> > +./libgit2_tests -t | sed -e 's|ok .* - # SKIP|SKIP:|' -e 's|not ok .* -|FAIL:|'  -e 's|ok .* -|PASS:|'
> > diff --git a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > index ee4d79b11a..aca8b94551 100644
> > --- a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > +++ b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
> > @@ -5,12 +5,15 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=112e6bb421dea73cd41de09e777f2d2c"
> >
> >  DEPENDS = "curl openssl zlib libssh2 libgcrypt libpcre2"
> >
> > -SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https"
> > +SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https \
> > +           file://0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch \
> > +           file://run-ptest \
> > +          "
> >  SRCREV = "fbea439d4b6fc91c6b619d01b85ab3b7746e4c19"
> >
> >  S = "${WORKDIR}/git"
> >
> > -inherit cmake
> > +inherit cmake ptest
> >
> >  EXTRA_OECMAKE = "\
> >      -DBUILD_CLAR=OFF \
> > @@ -19,4 +22,15 @@ EXTRA_OECMAKE = "\
> >      -DREGEX_BACKEND='pcre2' \
> >  "
> >
> > +EXTRA_OECMAKE_PTEST = " -DBUILD_CLAR=ON -DVALGRIND=ON -DCLAR_FIXTURES_DIR=${PTEST_PATH}/tests "
> > +
> > +EXTRA_OECMAKE += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '${EXTRA_OECMAKE_PTEST}', '', d)} "
> > +
> > +do_install_ptest(){
> > +        install -d ${D}${PTEST_PATH}/tests/
> > +        install ${B}/libgit2_tests ${D}${PTEST_PATH}/tests/
> > +        cp ${S}/tests/resources/ ${D}${PTEST_PATH}/tests/ -rf }
> > +
> > +
> >  BBCLASSEXTEND = "native"
> > --
> > 2.39.0
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#176788):
> > https://lists.openembedded.org/g/openembedded-core/message/176788
> > Mute This Topic: https://lists.openembedded.org/mt/96779266/1686489
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: 
> > https://lists.openembedded.org/g/openembedded-core/unsub
> > [alex.kanavin@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Luca Ceresoli Feb. 7, 2023, 8:28 a.m. UTC | #5
Hello Jason,

On Mon, 6 Feb 2023 00:44:01 -0800
"jason.lau" <Haitao.Liu@windriver.com> wrote:

> Add ptest for libgit2.
> ALl test passed on a trial run and it took around 21m56s to execute so
> added curl-ptest to PTESTS_SLOW.
> 
> Signed-off-by: Liu Haitao <haitao.liu@windriver.com>

I have run this patch through the autobuilders and it shows a failed
ptest:

{'libgit2': ['submodule::modify::set_relative_url', 'worktree::worktree::path']}

Here are the build logs:

https://autobuilder.yoctoproject.org/typhoon/#/builders/82/builds/4454/steps/12/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/81/builds/4651/steps/12/logs/stdio

The ptest log shows:

FAIL: submodule::modify::set_relative_url
    ---
    reason: |
      String mismatch: expected_value != buf.ptr
      '/tmp/libgit2_tests_xhUI5o/relative-url' != '/var/volatile/tmp/libgit2_tests_xhUI5o/relative-url' (at byte 1)
    at:
      file: '/usr/src/debug/libgit2/1.5.0-r0/tests/libgit2/config/config_helpers.c'
      line: 37
      function: 'assert_config_entry_value'
    ---

and:

FAIL: worktree::worktree::path
    ---
    reason: |
      String mismatch: git_worktree_path(wt) != expected_path.ptr
      '/var/volatile/tmp/libgit2_tests_xhUI5o/testrepo-worktree' != '/tmp/libgit2_tests_xhUI5o/testrepo-worktree' (at byte 1)
    at:
      file: '/usr/src/debug/libgit2/1.5.0-r0/tests/libgit2/worktree/worktree.c'
      line: 417
      function: 'test_worktree_worktree__path'
    ---
Liu, Haitao Feb. 7, 2023, 9:11 a.m. UTC | #6
HI Luca,

I have not encountered these failed ptests in my side.  Did you test it with qemu(runqemu) ?  Let's me check it again. 

Thanks,
haitao

-----Original Message-----
From: Luca Ceresoli <luca.ceresoli@bootlin.com> 
Sent: Tuesday, February 7, 2023 4:29 PM
To: Liu, Haitao <Haitao.Liu@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][PATCH] libgit: add ptest for libgit2

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hello Jason,

On Mon, 6 Feb 2023 00:44:01 -0800
"jason.lau" <Haitao.Liu@windriver.com> wrote:

> Add ptest for libgit2.
> ALl test passed on a trial run and it took around 21m56s to execute so 
> added curl-ptest to PTESTS_SLOW.
>
> Signed-off-by: Liu Haitao <haitao.liu@windriver.com>

I have run this patch through the autobuilders and it shows a failed
ptest:

{'libgit2': ['submodule::modify::set_relative_url', 'worktree::worktree::path']}

Here are the build logs:

https://autobuilder.yoctoproject.org/typhoon/#/builders/82/builds/4454/steps/12/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/81/builds/4651/steps/12/logs/stdio

The ptest log shows:

FAIL: submodule::modify::set_relative_url
    ---
    reason: |
      String mismatch: expected_value != buf.ptr
      '/tmp/libgit2_tests_xhUI5o/relative-url' != '/var/volatile/tmp/libgit2_tests_xhUI5o/relative-url' (at byte 1)
    at:
      file: '/usr/src/debug/libgit2/1.5.0-r0/tests/libgit2/config/config_helpers.c'
      line: 37
      function: 'assert_config_entry_value'
    ---

and:

FAIL: worktree::worktree::path
    ---
    reason: |
      String mismatch: git_worktree_path(wt) != expected_path.ptr
      '/var/volatile/tmp/libgit2_tests_xhUI5o/testrepo-worktree' != '/tmp/libgit2_tests_xhUI5o/testrepo-worktree' (at byte 1)
    at:
      file: '/usr/src/debug/libgit2/1.5.0-r0/tests/libgit2/worktree/worktree.c'
      line: 417
      function: 'test_worktree_worktree__path'
    ---

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Luca Ceresoli Feb. 7, 2023, 10:34 a.m. UTC | #7
Hi Haitao,

On Tue, 7 Feb 2023 09:11:31 +0000
"Liu, Haitao" <Haitao.Liu@windriver.com> wrote:

> HI Luca,
> 
> I have not encountered these failed ptests in my side.  Did you test it with qemu(runqemu) ?  Let's me check it again. 

Those tests have been executed by the yocto autobuilders and yes, they
use qemu.
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 5422ecd378..9b88b58070 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -104,6 +104,7 @@  PTESTS_SLOW = "\
     tcl-ptest \
     util-linux-ptest \
     valgrind-ptest \
+    libgit2-ptest \
 "
 
 PTESTS_SLOW:remove:riscv64 = "valgrind-ptest"
diff --git a/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch
new file mode 100644
index 0000000000..f547d29e8a
--- /dev/null
+++ b/meta/recipes-support/libgit2/libgit2/0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch
@@ -0,0 +1,54 @@ 
+From 7ae59e785260bb820cf1449da84140f8ae613e9f Mon Sep 17 00:00:00 2001
+From: Liu Haitao <haitao.liu@windriver.com>
+Date: Mon, 6 Feb 2023 06:40:20 +0200
+Subject: [PATCH] tests: add CLAR_FIXTURES_DIR for ptest
+
+Upstream-Status: Inappropriate [yocto specific]
+
+Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
+---
+ tests/libgit2/CMakeLists.txt | 8 +++++++-
+ tests/util/CMakeLists.txt    | 8 +++++++-
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/tests/libgit2/CMakeLists.txt b/tests/libgit2/CMakeLists.txt
+index 27f421ad6..e1a95a610 100644
+--- a/tests/libgit2/CMakeLists.txt
++++ b/tests/libgit2/CMakeLists.txt
+@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
+ ENDIF()
+ 
+ set(CLAR_PATH "${PROJECT_SOURCE_DIR}/tests/clar")
+-set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
++
++IF (CLAR_FIXTURES_DIR)
++	SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")
++ELSE()
++	set(CLAR_FIXTURES "${PROJECT_SOURCE_DIR}/tests/resources/")
++ENDIF()
++
+ set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+ add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
+ add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
+diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
+index 232590ffd..c736bb3bb 100644
+--- a/tests/util/CMakeLists.txt
++++ b/tests/util/CMakeLists.txt
+@@ -9,7 +9,13 @@ if(NOT PYTHONINTERP_FOUND)
+ ENDIF()
+ 
+ set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
+-set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
++
++IF (CLAR_FIXTURES_DIR)
++	SET(CLAR_FIXTURES "${CLAR_FIXTURES_DIR}/resources/")	
++ELSE()
++	set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
++ENDIF()
++
+ set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+ add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
+ add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
+-- 
+2.39.1
+
diff --git a/meta/recipes-support/libgit2/libgit2/run-ptest b/meta/recipes-support/libgit2/libgit2/run-ptest
new file mode 100644
index 0000000000..66e0392af6
--- /dev/null
+++ b/meta/recipes-support/libgit2/libgit2/run-ptest
@@ -0,0 +1,7 @@ 
+#!/bin/sh 
+
+cd tests
+
+export CLAR_SUMMARY="${PWD}/results.xml"
+
+./libgit2_tests -t | sed -e 's|ok .* - # SKIP|SKIP:|' -e 's|not ok .* -|FAIL:|'  -e 's|ok .* -|PASS:|' 
diff --git a/meta/recipes-support/libgit2/libgit2_1.5.0.bb b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
index ee4d79b11a..aca8b94551 100644
--- a/meta/recipes-support/libgit2/libgit2_1.5.0.bb
+++ b/meta/recipes-support/libgit2/libgit2_1.5.0.bb
@@ -5,12 +5,15 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=112e6bb421dea73cd41de09e777f2d2c"
 
 DEPENDS = "curl openssl zlib libssh2 libgcrypt libpcre2"
 
-SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/libgit2/libgit2.git;branch=main;protocol=https \
+           file://0001-tests-add-CLAR_FIXTURES_DIR-for-ptest.patch \
+           file://run-ptest \
+          "
 SRCREV = "fbea439d4b6fc91c6b619d01b85ab3b7746e4c19"
 
 S = "${WORKDIR}/git"
 
-inherit cmake
+inherit cmake ptest
 
 EXTRA_OECMAKE = "\
     -DBUILD_CLAR=OFF \
@@ -19,4 +22,15 @@  EXTRA_OECMAKE = "\
     -DREGEX_BACKEND='pcre2' \
 "
 
+EXTRA_OECMAKE_PTEST = " -DBUILD_CLAR=ON -DVALGRIND=ON -DCLAR_FIXTURES_DIR=${PTEST_PATH}/tests "
+
+EXTRA_OECMAKE += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '${EXTRA_OECMAKE_PTEST}', '', d)} "
+
+do_install_ptest(){
+        install -d ${D}${PTEST_PATH}/tests/
+        install ${B}/libgit2_tests ${D}${PTEST_PATH}/tests/
+        cp ${S}/tests/resources/ ${D}${PTEST_PATH}/tests/ -rf
+}
+
+
 BBCLASSEXTEND = "native"