Say I am hashing hashes (taking the hash of a previous hash) for an endless amount of time.

How many times would it take, on average, to fall into a loop when using SHA-2 (more specifically SHA-256 and SHA-512), like such:

    original text = z (can be any string)
    hash z = b
    hash b = c
    hash c = d

    ...

    hash n = b (restarting loop)

or more literally,

    original text = "test"
    SHA-256 of "test" = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
    SHA-256 of "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" = "7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c"

    ...
    
    SHA-256 of n = SHA-256 of "test" = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"

How many attempts, on average, would this take?