302 lines
18 KiB
Go
302 lines
18 KiB
Go
package goh
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func testData() io.Reader {
|
|
return strings.NewReader(`
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>The Linux Kernel Archives</title>
|
|
<meta charset="utf-8" />
|
|
<link rel="icon" type="image/png" href="https://www.kernel.org/theme/images/logos/favicon.png" />
|
|
<link rel="stylesheet" href="https://www.kernel.org/theme/css/main.css" type="text/css" />
|
|
<link href="https://www.kernel.org/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="The Linux Kernel Archives Atom Feed" />
|
|
|
|
<link href="https://www.kernel.org/feeds/kdist.xml" type="application/atom+xml" rel="alternate" title="Latest Linux Kernel Releases" />
|
|
|
|
<!--[if IE]>
|
|
<script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
|
|
|
<!--[if lte IE 7]>
|
|
<link rel="stylesheet" type="text/css" media="all" href="https://www.kernel.org/css/ie.css"/>
|
|
<script src="https://www.kernel.org/js/IE8.js" type="text/javascript"></script><![endif]-->
|
|
|
|
<!--[if lt IE 7]>
|
|
<link rel="stylesheet" type="text/css" media="all" href="https://www.kernel.org/css/ie6.css"/><![endif]-->
|
|
|
|
</head>
|
|
|
|
<body id="index" class="home">
|
|
<header id="banner" class="body">
|
|
<div id="tux-gear"></div>
|
|
<h1><a href="https://www.kernel.org/">The Linux Kernel Archives </a></h1>
|
|
<nav><ul>
|
|
<li ><a href="https://www.kernel.org/category/about.html">About</a></li>
|
|
<li ><a href="https://www.kernel.org/category/contact-us.html">Contact us</a></li>
|
|
<li ><a href="https://www.kernel.org/category/faq.html">FAQ</a></li>
|
|
<li ><a href="https://www.kernel.org/category/releases.html">Releases</a></li>
|
|
<li ><a href="https://www.kernel.org/category/signatures.html">Signatures</a></li>
|
|
<li ><a href="https://www.kernel.org/category/site-news.html">Site news</a></li>
|
|
</ul></nav>
|
|
</header><!-- /#banner -->
|
|
|
|
<aside id="featured" class="body">
|
|
<article>
|
|
<table id="protocols">
|
|
<tr>
|
|
<th>Protocol</th>
|
|
<th>Location</th>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="https://www.ietf.org/rfc/rfc2616.txt">HTTP</a></td>
|
|
<td><a href="https://www.kernel.org/pub/">https://www.kernel.org/pub/</a></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><a href="https://git-scm.com/">GIT</a></td>
|
|
<td><a href="https://git.kernel.org/">https://git.kernel.org/</a></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><a href="https://rsync.samba.org/">RSYNC</a></td>
|
|
<td>rsync://rsync.kernel.org/pub/</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<table id="latest">
|
|
<tr>
|
|
<td colspan="2" id="latest_label">
|
|
<strong>Latest Release</strong>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td id="latest_link">
|
|
<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.11.tar.xz">6.11</a>
|
|
</td>
|
|
<td id="latest_button">
|
|
<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.11.tar.xz"><img src="https://www.kernel.org/theme/images/icons/downloadarrow_small.png" width="48" height="48" border="0" alt="Download"/></a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<!--//
|
|
// Wait! Are you looking at the source because you are trying to parse the releases table?
|
|
// Save yourself a lot of effort and use these instead:
|
|
// - https://www.kernel.org/releases.json
|
|
// - https://www.kernel.org/finger_banner
|
|
//-->
|
|
<table id="releases">
|
|
<tr align="left">
|
|
<td>mainline:</td>
|
|
<td><strong>6.11</strong></td>
|
|
<td>2024-09-15</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.11.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.11.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-6.11.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td> </td>
|
|
<td>[<a href="https://git.kernel.org/torvalds/ds/v6.11/v6.10" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/torvalds/h/v6.11" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>stable:</td>
|
|
<td><strong>6.10.11</strong></td>
|
|
<td>2024-09-18</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.10.11.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.10.11.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-6.10.11.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/incr/patch-6.10.10-11.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v6.10.11/v6.10.10" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v6.10.11" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.10.11" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>longterm:</td>
|
|
<td><strong>6.6.52</strong></td>
|
|
<td>2024-09-18</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.52.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.52.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-6.6.52.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/incr/patch-6.6.51-52.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v6.6.52/v6.6.51" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v6.6.52" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.6.52" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>longterm:</td>
|
|
<td><strong>6.1.111</strong></td>
|
|
<td>2024-09-18</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.111.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.111.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-6.1.111.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/incr/patch-6.1.110-111.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v6.1.111/v6.1.110" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v6.1.111" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.1.111" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>longterm:</td>
|
|
<td><strong>5.15.167</strong></td>
|
|
<td>2024-09-12</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.167.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.167.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.15.167.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/incr/patch-5.15.166-167.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v5.15.167/v5.15.166" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v5.15.167" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.167" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>longterm:</td>
|
|
<td><strong>5.10.226</strong></td>
|
|
<td>2024-09-12</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.226.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.226.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.10.226.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/incr/patch-5.10.225-226.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v5.10.226/v5.10.225" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v5.10.226" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.10.226" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>longterm:</td>
|
|
<td><strong>5.4.284</strong></td>
|
|
<td>2024-09-12</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.284.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.284.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.4.284.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/incr/patch-5.4.283-284.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v5.4.284/v5.4.283" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v5.4.284" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.4.284" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>longterm:</td>
|
|
<td><strong>4.19.322</strong></td>
|
|
<td>2024-09-12</td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.322.tar.xz" title="Download complete tarball">tarball</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.322.tar.sign" title="Download PGP verification signature">pgp</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v4.x/patch-4.19.322.xz" title="Download patch to previous mainline">patch</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v4.x/incr/patch-4.19.321-322.xz" title="Download incremental patch">inc. patch</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/ds/v4.19.322/v4.19.321" title="View diff in cgit">view diff</a>] </td>
|
|
<td>[<a href="https://git.kernel.org/stable/h/v4.19.322" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td>[<a href="https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.19.322" title="View detailed change logs">changelog</a>] </td>
|
|
</tr>
|
|
<tr align="left">
|
|
<td>linux-next:</td>
|
|
<td><strong>next-20240920</strong></td>
|
|
<td>2024-09-20</td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td>[<a href="https://git.kernel.org/next/linux-next/h/next-20240920" title="Browse the git tree using cgit">browse</a>] </td>
|
|
<td> </td>
|
|
</tr>
|
|
</table>
|
|
</article>
|
|
</aside>
|
|
<section id="extras" class="body">
|
|
<div class="blogroll">
|
|
<h2>Other resources</h2>
|
|
<ul>
|
|
<li><a href="https://git.kernel.org/">Git Trees</a></li>
|
|
<li><a href="https://docs.kernel.org/">Documentation</a></li>
|
|
<li><a href="https://lore.kernel.org/">Kernel Mailing Lists</a></li>
|
|
<li><a href="https://patchwork.kernel.org/">Patchwork</a></li>
|
|
<li><a href="https://www.wiki.kernel.org/">Wikis</a></li>
|
|
<li><a href="https://bugzilla.kernel.org/">Bugzilla</a></li>
|
|
<li><a href="https://mirrors.kernel.org/">Mirrors</a></li>
|
|
<li><a href="https://www.linux.com/">Linux.com</a></li>
|
|
<li><a href="https://www.linuxfoundation.org/">Linux Foundation</a></li>
|
|
</ul>
|
|
</div><!-- /.blogroll -->
|
|
<div class="social">
|
|
<h2>Social</h2>
|
|
<ul>
|
|
<li><a href="https://www.kernel.org/feeds/all.atom.xml" type="application/atom+xml" rel="alternate">Site Atom feed</a></li>
|
|
<li><a href="https://www.kernel.org/feeds/kdist.xml" type="application/atom+xml" rel="alternate">Releases Atom Feed</a></li>
|
|
|
|
<li><a href="https://planet.kernel.org/">Kernel Planet</a></li>
|
|
</ul>
|
|
</div><!-- /.social -->
|
|
</section><!-- /#extras -->
|
|
|
|
<footer id="contentinfo" class="body">
|
|
<address id="about" class="vcard body">
|
|
This site is operated by the Linux Kernel Organization, Inc., a <a href="https://www.kernel.org/nonprofit.html">501(c)3 nonprofit corporation</a>, with support from the following sponsors.
|
|
</address><!-- /#about -->
|
|
|
|
<address id="donors">
|
|
<a href="https://metal.equinix.com/"><img src="https://www.kernel.org/theme/images/logos/equinix-metal.png"
|
|
alt="Equinix Metal" height="35" width="328" /></a>
|
|
|
|
<a href="https://www.fastly.com/"><img src="https://www.kernel.org/theme/images/logos/fastly-logo.png"
|
|
alt="Fastly" width="91" height="35" /></a>
|
|
|
|
<a href="https://www.constellix.com/"><img src="https://www.kernel.org/theme/images/logos/constellix-green-logo.png"
|
|
alt="Constellix" width="193" height="21" /></a>
|
|
<br />
|
|
<a href="https://www.redhat.com/"><img src="https://www.kernel.org/theme/images/logos/redhat-community.png"
|
|
alt="Red Hat" height="36" width="150" /></a>
|
|
|
|
<a href="https://www.purestorage.com/"><img src="https://www.kernel.org/theme/images/logos/purestorage.png"
|
|
alt="PureStorage" width="179" height="45" /></a>
|
|
|
|
<a href="https://www.google.com/"><img src="https://www.kernel.org/theme/images/logos/google.png"
|
|
alt="Google" height="42" width="128" /></a>
|
|
<br/> <br/>
|
|
<a href="https://www.linuxfoundation.org/"><img src="https://www.kernel.org/theme/images/logos/thelinuxfoundation.png"
|
|
alt="The Linux Foundation" width="137" height="45" /></a>
|
|
</address><!-- /#about -->
|
|
</footer><!-- /#contentinfo -->
|
|
|
|
</body>
|
|
</html>`)
|
|
}
|
|
|
|
func TestNewParser(t *testing.T) {
|
|
parser, err := NewParser(testData())
|
|
assert.NoError(t, err)
|
|
value, err := parser.Find("footer#contentinfo.body address#about.vcard.body a").Value()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "501(c)3 nonprofit corporation", value)
|
|
}
|
|
|
|
func Test_parser_Find(t *testing.T) {
|
|
parser, err := NewParser(testData())
|
|
assert.NoError(t, err)
|
|
value, err := parser.Find("section#extras div.blogroll h2").Value()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "Other resources", value)
|
|
value, err = parser.Find("section#extras div.social").Attribute("class")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "social", value)
|
|
}
|
|
|
|
func Test_parser_FindAll(t *testing.T) {
|
|
parser, err := NewParser(testData())
|
|
assert.NoError(t, err)
|
|
values, err := parser.FindAll("section#extras div.blogroll ul li").Values("li a")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, []string{"Git Trees", "Documentation", "Kernel Mailing Lists", "Patchwork", "Wikis", "Bugzilla", "Mirrors", "Linux.com", "Linux Foundation"}, values)
|
|
attributes, err := parser.FindAll("footer#contentinfo.body address#donors a").Attributes("a img", "alt")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, []string{"Equinix Metal", "Fastly", "Constellix", "Red Hat", "PureStorage", "Google", "The Linux Foundation"}, attributes)
|
|
}
|
|
|
|
func Test_parser_Find_FindAll_Find(t *testing.T) {
|
|
parser, err := NewParser(testData())
|
|
assert.NoError(t, err)
|
|
attribute, err := parser.Find("footer#contentinfo.body").FindAll("address#donors a").Find("a img").Attribute("alt")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "Equinix Metal", attribute)
|
|
}
|